[asterisk-commits] may: branch may/chan_ooh323_rework r209613 - /team/may/chan_ooh323_rework/add...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 30 15:28:34 CDT 2009


Author: may
Date: Thu Jul 30 15:28:30 2009
New Revision: 209613

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=209613
Log:
Change pthread_cond to semaphore for synchronisation between gatekeeper
and call thread

Modified:
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooCommon.h
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c
    team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.c Thu Jul 30 15:28:30 2009
@@ -62,7 +62,7 @@
       return NULL;
    } 
    memset(call, 0, sizeof(OOH323CallData));
-   ast_cond_init(&call->gkWait, NULL);
+   sem_init(&call->gkWait, 0, 0);
    ast_mutex_init(&call->Lock);
    call->pctxt = pctxt;
    call->msgctxt = msgctxt;

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCalls.h Thu Jul 30 15:28:30 2009
@@ -143,7 +143,7 @@
    OOCTXT               *pctxt;
    OOCTXT               *msgctxt;
    pthread_t		callThread;
-   ast_cond_t		gkWait;
+   sem_t		gkWait;
    ast_mutex_t		Lock;
    OOBOOL 		Monitor;
    OOSOCKET		CmdChan;

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooCommon.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooCommon.h?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooCommon.h (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooCommon.h Thu Jul 30 15:28:30 2009
@@ -41,6 +41,7 @@
 #include <unistd.h>
 #include <arpa/inet.h>
 #endif
+#include <semaphore.h>
 
 /** 
  * @ingroup cruntime C Runtime Common Constant and Type Definitions.

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooGkClient.c Thu Jul 30 15:28:30 2009
@@ -1950,7 +1950,7 @@
                        pCallAdmInfo->call->callToken);
 
 	 pCallAdmInfo->call->callState = OO_CALL_CONNECTING;
-	 ast_cond_broadcast(&pCallAdmInfo->call->gkWait);
+	 sem_post(&pCallAdmInfo->call->gkWait);
          /* ooH323CallAdmitted( pCallAdmInfo->call); */
 
          dListRemove(&pGkClient->callsPendingList, pNode);
@@ -2049,7 +2049,7 @@
          break;
    }
 
-   ast_cond_broadcast(&pCallAdmInfo->call->gkWait);
+   sem_post(&pCallAdmInfo->call->gkWait);
    return OO_OK;   
 }
 

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/oochannels.c Thu Jul 30 15:28:30 2009
@@ -959,7 +959,7 @@
    ast_mutex_lock(&call->Lock);
    ast_mutex_unlock(&call->Lock);
    ast_mutex_destroy(&call->Lock);
-   ast_cond_destroy(&call->gkWait);
+   sem_destroy(&call->gkWait);
    pctxt = call->pctxt;
    freeContext(pctxt);
    free(pctxt);

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooh323.c Thu Jul 30 15:28:30 2009
@@ -1322,7 +1322,6 @@
    int type = q931Msg->messageType;
    struct timespec ts;
    int gkWaits;
-   ast_mutex_t gmutex;
    switch(type)
    {
       case Q931SetupMsg: /* SETUP message is received */
@@ -1354,17 +1353,13 @@
 	       // ast_mutex_lock(&call->Lock);
                ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, 
                                                     FALSE);
-               ast_mutex_init(&gmutex);
                for (gkWaits = 0; gkWaits < 1000; gkWaits++) {
                  clock_gettime(CLOCK_REALTIME, &ts);
                  ts.tv_nsec += 24000000;
-                 ast_mutex_lock(&gmutex);
-                 ast_cond_timedwait(&call->gkWait, &gmutex, &ts);
-                 ast_mutex_unlock(&gmutex);
+                 sem_timedwait(&call->gkWait, &ts);
                  if (call->callState != OO_CALL_WAITING_ADMISSION)
 			break;
                }
-               ast_mutex_destroy(&gmutex);
                // ast_mutex_unlock(&call->Lock);
 
             }

Modified: team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c?view=diff&rev=209613&r1=209612&r2=209613
==============================================================================
--- team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c (original)
+++ team/may/chan_ooh323_rework/addons/ooh323c/src/ooq931.c Thu Jul 30 15:28:30 2009
@@ -1949,7 +1949,6 @@
    OOCTXT *pctxt;
    ooAliases *pNewAlias=NULL, *alias=NULL;
    struct timespec ts;
-   ast_mutex_t gmutex;
    int i=0, irand=0, ret = OO_OK;
    /* Note: We keep same callToken, for new call which is going
       to replace an existing call, thus treating it as a single call.*/
@@ -2007,11 +2006,7 @@
       ast_mutex_lock(&fwdedCall->Lock);
       clock_gettime(CLOCK_REALTIME, &ts);
       ts.tv_sec += 24;
-      ast_mutex_init(&gmutex);
-      ast_mutex_lock(&gmutex);
-      ast_cond_timedwait(&fwdedCall->gkWait, &gmutex, &ts);
-      ast_mutex_unlock(&gmutex);
-      ast_mutex_destroy(&gmutex);
+      sem_timedwait(&fwdedCall->gkWait, &ts);
       if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) /* GK is not responding */
           fwdedCall->callState = OO_CALL_CLEAR;
       ast_mutex_unlock(&fwdedCall->Lock);
@@ -2053,7 +2048,6 @@
    char *ip=NULL, *port = NULL;
    struct timespec ts;
    int gkWaits;
-   ast_mutex_t gmutex;
 
    if(!dest)
    {
@@ -2134,17 +2128,13 @@
      call->callState = OO_CALL_WAITING_ADMISSION;
      // ast_mutex_lock(&call->Lock);
      ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE);
-     ast_mutex_init(&gmutex);
      for (gkWaits = 0; gkWaits < 1000; gkWaits++) {
        clock_gettime(CLOCK_REALTIME, &ts);
        ts.tv_nsec += 24000000;
-       ast_mutex_lock(&gmutex);
-       ast_cond_timedwait(&call->gkWait, &gmutex, &ts);
-       ast_mutex_unlock(&gmutex);
+       sem_timedwait(&call->gkWait, &ts);
        if (call->callState != OO_CALL_WAITING_ADMISSION)
                         break;
      }
-     ast_mutex_destroy(&gmutex);
      // ast_mutex_unlock(&call->Lock);
 
    }




More information about the asterisk-commits mailing list