mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 17:22:21 +00:00
fix mutex locking in Windows and take back boost 10ms polling, is needed for now
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@933 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
15c93b5c0d
commit
39974a3536
@ -377,7 +377,7 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
|
|||||||
OUTBOUND_REQUESTS[r].span = span;
|
OUTBOUND_REQUESTS[r].span = span;
|
||||||
|
|
||||||
if (sangomabc_connection_write(&sangoma_boost_data->mcon, &event) <= 0) {
|
if (sangomabc_connection_write(&sangoma_boost_data->mcon, &event) <= 0) {
|
||||||
zap_log(ZAP_LOG_CRIT, "Failed to tx on ISUP socket [%s]\n", strerror(errno));
|
zap_log(ZAP_LOG_CRIT, "Failed to tx boost event [%s]\n", strerror(errno));
|
||||||
status = ZAP_FAIL;
|
status = ZAP_FAIL;
|
||||||
*zchan = NULL;
|
*zchan = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
@ -1416,7 +1416,7 @@ static void *zap_sangoma_boost_run(zap_thread_t *me, void *obj)
|
|||||||
zap_span_t *span = (zap_span_t *) obj;
|
zap_span_t *span = (zap_span_t *) obj;
|
||||||
sangomabc_connection_t *mcon, *pcon;
|
sangomabc_connection_t *mcon, *pcon;
|
||||||
uint32_t ms = 10;
|
uint32_t ms = 10;
|
||||||
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
|
||||||
|
|
||||||
mcon = &sangoma_boost_data->mcon;
|
mcon = &sangoma_boost_data->mcon;
|
||||||
pcon = &sangoma_boost_data->pcon;
|
pcon = &sangoma_boost_data->pcon;
|
||||||
@ -1466,7 +1466,7 @@ static void *zap_sangoma_boost_run(zap_thread_t *me, void *obj)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((activity = zap_boost_wait_event(span, -1)) < 0) {
|
if ((activity = zap_boost_wait_event(span, ms)) < 0) {
|
||||||
zap_log(ZAP_LOG_ERROR, "zap_boost_wait_event failed\n");
|
zap_log(ZAP_LOG_ERROR, "zap_boost_wait_event failed\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../../src/include;../../../src/isdn/include;"C:\Program Files\Sangoma""
|
AdditionalIncludeDirectories="../../../src/include;../../../src/isdn/include;"C:\Program Files\Sangoma\include""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
@ -64,7 +64,7 @@
|
|||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="openzap.lib libsangoma.lib"
|
AdditionalDependencies="openzap.lib libsangoma.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories=""$(OutDir)";C:\wanpipe\lib"
|
AdditionalLibraryDirectories=""$(OutDir)";"C:\Program Files\Sangoma\lib""
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
RandomizedBaseAddress="1"
|
RandomizedBaseAddress="1"
|
||||||
|
@ -38,10 +38,6 @@ struct zap_mutex {
|
|||||||
CRITICAL_SECTION mutex;
|
CRITICAL_SECTION mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct zap_condition {
|
|
||||||
HANDLE condition;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -52,12 +48,17 @@ struct zap_mutex {
|
|||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
struct zap_condition {
|
struct zap_condition {
|
||||||
|
#ifdef WIN32
|
||||||
|
HANDLE condition;
|
||||||
|
#else
|
||||||
pthread_cond_t condition;
|
pthread_cond_t condition;
|
||||||
pthread_mutex_t *mutex;
|
#endif
|
||||||
|
zap_mutex_t *mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct zap_thread {
|
struct zap_thread {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -250,13 +251,13 @@ OZ_DECLARE(zap_status_t) zap_condition_create(zap_condition_t **incondition, zap
|
|||||||
return ZAP_FAIL;
|
return ZAP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
condition->mutex = mutex;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
condition->condition = CreateEvent(NULL, FALSE, FALSE, NULL);
|
condition->condition = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
if (!condition->condition) {
|
if (!condition->condition) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
condition->mutex = &mutex->mutex;
|
|
||||||
if (pthread_cond_init(&condition->condition, NULL)) {
|
if (pthread_cond_init(&condition->condition, NULL)) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -279,7 +280,9 @@ OZ_DECLARE(zap_status_t) zap_condition_wait(zap_condition_t *condition, int ms)
|
|||||||
#endif
|
#endif
|
||||||
zap_assert_return(condition != NULL, ZAP_FAIL, "Condition is null!\n");
|
zap_assert_return(condition != NULL, ZAP_FAIL, "Condition is null!\n");
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
zap_mutex_unlock(condition->mutex);
|
||||||
res = WaitForSingleObject(condition->condition, ms > 0 ? ms : INFINITE);
|
res = WaitForSingleObject(condition->condition, ms > 0 ? ms : INFINITE);
|
||||||
|
zap_mutex_lock(condition->mutex);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case WAIT_ABANDONED:
|
case WAIT_ABANDONED:
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
@ -298,9 +301,9 @@ OZ_DECLARE(zap_status_t) zap_condition_wait(zap_condition_t *condition, int ms)
|
|||||||
struct timespec waitms;
|
struct timespec waitms;
|
||||||
waitms.tv_sec = time(NULL) + ( ms / 1000 );
|
waitms.tv_sec = time(NULL) + ( ms / 1000 );
|
||||||
waitms.tv_nsec = 1000 * 1000 * ( ms % 1000 );
|
waitms.tv_nsec = 1000 * 1000 * ( ms % 1000 );
|
||||||
res = pthread_cond_timedwait(&condition->condition, condition->mutex, &waitms);
|
res = pthread_cond_timedwait(&condition->condition, condition->mutex->mutex, &waitms);
|
||||||
} else {
|
} else {
|
||||||
res = pthread_cond_wait(&condition->condition, condition->mutex);
|
res = pthread_cond_wait(&condition->condition, condition->mutex->mutex);
|
||||||
}
|
}
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
if (res == ETIMEDOUT) {
|
if (res == ETIMEDOUT) {
|
||||||
@ -340,8 +343,8 @@ OZ_DECLARE(zap_status_t) zap_condition_destroy(zap_condition_t **incondition)
|
|||||||
if (pthread_cond_destroy(&condition->condition)) {
|
if (pthread_cond_destroy(&condition->condition)) {
|
||||||
return ZAP_FAIL;
|
return ZAP_FAIL;
|
||||||
}
|
}
|
||||||
zap_safe_free(condition);
|
|
||||||
#endif
|
#endif
|
||||||
|
zap_safe_free(condition);
|
||||||
*incondition = NULL;
|
*incondition = NULL;
|
||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user