]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix mutex locking in Windows and take back boost 10ms polling, is needed for now
authorMoises Silva <moy@sangoma.com>
Wed, 9 Dec 2009 20:35:53 +0000 (20:35 +0000)
committerMoises Silva <moy@sangoma.com>
Wed, 9 Dec 2009 20:35:53 +0000 (20:35 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@933 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/freetdm/src/ozmod/ozmod_sangoma_boost/ozmod_sangoma_boost.c
libs/freetdm/src/ozmod/ozmod_wanpipe/ozmod_wanpipe.2008.vcproj
libs/freetdm/src/zap_threadmutex.c

index a1b289a06bd7f54633a09afbf3461cb4c011c8c9..b4af623c0a76af5629d9481d014e0d0f22bbf786 100644 (file)
@@ -377,7 +377,7 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
        OUTBOUND_REQUESTS[r].span = span;
 
        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;
                *zchan = NULL;
                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;
        sangomabc_connection_t *mcon, *pcon;
        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;
        pcon = &sangoma_boost_data->pcon;       
@@ -1466,7 +1466,7 @@ static void *zap_sangoma_boost_run(zap_thread_t *me, void *obj)
                        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");
                        goto error;
                }
index 5802643fec51c4792d2ec9a011203ccb087a22c4..5585e5bfdd394d1f3edc50551ed24a578ac9839e 100644 (file)
@@ -41,7 +41,7 @@
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="../../../src/include;../../../src/isdn/include;&quot;C:\Program Files\Sangoma&quot;"\r
+                               AdditionalIncludeDirectories="../../../src/include;../../../src/isdn/include;&quot;C:\Program Files\Sangoma\include&quot;"\r
                                PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
@@ -64,7 +64,7 @@
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="openzap.lib libsangoma.lib"\r
                                LinkIncremental="2"\r
-                               AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;C:\wanpipe\lib"\r
+                               AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;C:\Program Files\Sangoma\lib&quot;"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="1"\r
                                RandomizedBaseAddress="1"\r
index 4c633555e497b31e37cb77150cbc8f1dfdfd92f0..f5cc4a6117d44754480c76273b7726351b1cbe4f 100644 (file)
@@ -38,10 +38,6 @@ struct zap_mutex {
        CRITICAL_SECTION mutex;
 };
 
-struct zap_condition {
-       HANDLE condition;
-};
-
 #else
 
 #include <pthread.h>
@@ -52,12 +48,17 @@ struct zap_mutex {
        pthread_mutex_t mutex;
 };
 
+#endif
+
 struct zap_condition {
+#ifdef WIN32
+       HANDLE condition;
+#else
        pthread_cond_t condition;
-       pthread_mutex_t *mutex;
+#endif
+       zap_mutex_t *mutex;
 };
 
-#endif
 
 struct zap_thread {
 #ifdef WIN32
@@ -250,13 +251,13 @@ OZ_DECLARE(zap_status_t) zap_condition_create(zap_condition_t **incondition, zap
                return ZAP_FAIL;
        }
 
+       condition->mutex = mutex;
 #ifdef WIN32
        condition->condition = CreateEvent(NULL, FALSE, FALSE, NULL);
        if (!condition->condition) {
                goto failed;
        }
 #else
-       condition->mutex = &mutex->mutex;
        if (pthread_cond_init(&condition->condition, NULL)) {
                goto failed;
        }
@@ -279,7 +280,9 @@ OZ_DECLARE(zap_status_t) zap_condition_wait(zap_condition_t *condition, int ms)
 #endif
        zap_assert_return(condition != NULL, ZAP_FAIL, "Condition is null!\n");
 #ifdef WIN32
+       zap_mutex_unlock(condition->mutex);
        res = WaitForSingleObject(condition->condition, ms > 0 ? ms : INFINITE);
+       zap_mutex_lock(condition->mutex);
        switch (res) {
        case WAIT_ABANDONED:
        case WAIT_TIMEOUT:
@@ -298,9 +301,9 @@ OZ_DECLARE(zap_status_t) zap_condition_wait(zap_condition_t *condition, int ms)
                struct timespec waitms; 
                waitms.tv_sec = time(NULL) + ( 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 {
-               res = pthread_cond_wait(&condition->condition, condition->mutex);
+               res = pthread_cond_wait(&condition->condition, condition->mutex->mutex);
        }
        if (res != 0) {
                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)) {
                return ZAP_FAIL;
        }
-       zap_safe_free(condition);
 #endif
+       zap_safe_free(condition);
        *incondition = NULL;
        return ZAP_SUCCESS;
 }