[asterisk-commits] may: branch 1.8 r343281 - /branches/1.8/addons/ooh323c/src/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 3 11:16:02 CDT 2011


Author: may
Date: Thu Nov  3 11:15:58 2011
New Revision: 343281

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=343281
Log:
Final fix memleaks in GkClient codes, same for Timer codes.
(these memleaks stop development of gk codes, now i can continue)
Fix printHandler 'Unbalanced Structure' issues with locking printHandler
data for single thread.

Modified:
    branches/1.8/addons/ooh323c/src/dlist.c
    branches/1.8/addons/ooh323c/src/dlist.h
    branches/1.8/addons/ooh323c/src/ooGkClient.c
    branches/1.8/addons/ooh323c/src/ooTimer.c
    branches/1.8/addons/ooh323c/src/ooq931.c
    branches/1.8/addons/ooh323c/src/printHandler.c

Modified: branches/1.8/addons/ooh323c/src/dlist.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/dlist.c?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/dlist.c (original)
+++ branches/1.8/addons/ooh323c/src/dlist.c Thu Nov  3 11:15:58 2011
@@ -135,7 +135,7 @@
    pList->count--;
 }
 
-void dListFindAndRemove(DList* pList, void *data)
+void dListFindAndRemove(struct OOCTXT* pctxt, DList* pList, void *data)
 {
    DListNode *pNode, *pNextNode;
    for(pNode = pList->head; pNode !=0; pNode = pNextNode){
@@ -143,8 +143,10 @@
       if(pNode->data == data) /* pointer comparison*/
          break;
    }
-   if(pNode)
+   if(pNode) {
       dListRemove(pList, pNode);
+      memFreePtr(pctxt, pNode);
+   }
 }
     
 DListNode* dListFindByIndex (DList* pList, int index) 

Modified: branches/1.8/addons/ooh323c/src/dlist.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/dlist.h?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/dlist.h (original)
+++ branches/1.8/addons/ooh323c/src/dlist.h Thu Nov  3 11:15:58 2011
@@ -192,7 +192,7 @@
  *                     already be in the linked list structure.
  */
 EXTERN void  dListRemove (DList* pList, DListNode* node);
-void dListFindAndRemove(DList* pList, void* data);
+EXTERN void dListFindAndRemove(struct OOCTXT* pctxt, DList* pList, void* data);
 
 /** 
  * @}

Modified: branches/1.8/addons/ooh323c/src/ooGkClient.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/ooGkClient.c?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/ooGkClient.c (original)
+++ branches/1.8/addons/ooh323c/src/ooGkClient.c Thu Nov  3 11:15:58 2011
@@ -364,7 +364,7 @@
 
 int ooGkClientReceive(ooGkClient *pGkClient)
 {
-   ASN1OCTET recvBuf[1024];
+   ASN1OCTET recvBuf[ASN_K_ENCBUFSIZ];
    int recvLen;
    char remoteHost[32];
    int iFromPort=0;
@@ -375,7 +375,7 @@
    ast_mutex_lock(&pGkClient->Lock);
    pctxt = &pGkClient->msgCtxt;
 
-   recvLen = ooSocketRecvFrom(pGkClient->rasSocket, recvBuf, 1024, remoteHost,
+   recvLen = ooSocketRecvFrom(pGkClient->rasSocket, recvBuf, 2048, remoteHost,
                               32, &iFromPort);
    if(recvLen <0)
    {
@@ -858,7 +858,6 @@
          memFreePtr(&pGkClient->ctxt, pTimer->cbData);
          ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
          OOTRACEDBGA1("Deleted GRQ Timer.\n");
-         break;
       }
    }
 
@@ -1063,7 +1062,7 @@
          allocate storage for endpoint-identifier, and populate it from what the
          GK told us from the previous RCF. Only allocate on the first pass thru here */
       pRegReq->endpointIdentifier.data = 
-           (ASN116BITCHAR*)memAlloc(pctxt, pGkClient->gkId.nchars*sizeof(ASN116BITCHAR));
+           (ASN116BITCHAR*)memAlloc(pctxt, pGkClient->endpointId.nchars*sizeof(ASN116BITCHAR));
       if (pRegReq->endpointIdentifier.data) {
          pRegReq->endpointIdentifier.nchars = pGkClient->endpointId.nchars;
          pRegReq->m.endpointIdentifierPresent = TRUE;
@@ -1136,6 +1135,8 @@
    ooGkClientTimerCb *cbData;
    ASN1UINT regTTL=0;
    /* Extract Endpoint Id */
+   if (pGkClient->endpointId.data)
+	memFreePtr(&pGkClient->ctxt, pGkClient->endpointId.data);
    pGkClient->endpointId.nchars = 
                               pRegistrationConfirm->endpointIdentifier.nchars;
    pGkClient->endpointId.data = (ASN116BITCHAR*)memAlloc(&pGkClient->ctxt,
@@ -1288,7 +1289,6 @@
          memFreePtr(&pGkClient->ctxt, pTimer->cbData);
          ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
          OOTRACEDBGA1("Deleted RRQ Timer.\n");
-         break;
       }
    }
 

Modified: branches/1.8/addons/ooh323c/src/ooTimer.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/ooTimer.c?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/ooTimer.c (original)
+++ branches/1.8/addons/ooh323c/src/ooTimer.c Thu Nov  3 11:15:58 2011
@@ -79,7 +79,7 @@
 
 void ooTimerDelete (OOCTXT* pctxt, DList *pList, OOTimer* pTimer)
 {
-   dListFindAndRemove (pList, pTimer);
+   dListFindAndRemove (pctxt, pList, pTimer);
    memFreePtr (pctxt, pTimer);
 }
 
@@ -115,7 +115,7 @@
 
          stat = (*pTimer->timeoutCB)(pTimer->cbData);
 
-         if (0 != stat || !pTimer->reRegister) {
+         if (!pTimer->reRegister) {
             ooTimerDelete (pctxt, pList, pTimer);
          }
       }
@@ -175,7 +175,7 @@
 void ooTimerReset (OOCTXT* pctxt, DList *pList, OOTimer* pTimer)
 {
    if (pTimer->reRegister) {
-      dListFindAndRemove (pList, pTimer);
+      dListFindAndRemove (pctxt, pList, pTimer);
       ooTimerComputeExpireTime (pTimer);
       ooTimerInsertEntry (pctxt, pList, pTimer);
    }

Modified: branches/1.8/addons/ooh323c/src/ooq931.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/ooq931.c?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/ooq931.c (original)
+++ branches/1.8/addons/ooh323c/src/ooq931.c Thu Nov  3 11:15:58 2011
@@ -510,7 +510,7 @@
 
 int ooEncodeUUIE(OOCTXT* pctxt, Q931Message *q931msg)
 {
-   ASN1OCTET msgbuf[1024];
+   ASN1OCTET msgbuf[ASN_K_ENCBUFSIZ];
    ASN1OCTET * msgptr=NULL;
    int  len;
    ASN1BOOL aligned = TRUE;

Modified: branches/1.8/addons/ooh323c/src/printHandler.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/printHandler.c?view=diff&rev=343281&r1=343280&r2=343281
==============================================================================
--- branches/1.8/addons/ooh323c/src/printHandler.c (original)
+++ branches/1.8/addons/ooh323c/src/printHandler.c Thu Nov  3 11:15:58 2011
@@ -30,6 +30,7 @@
 #include "ootrace.h"
 
 EventHandler printHandler;
+AST_MUTEX_DEFINE_STATIC(printlock);
 
 static const char* pVarName;
 static int gIndentSpaces;
@@ -60,6 +61,7 @@
    printHandler->enumValue = &printEnumValue;
    printHandler->openTypeValue = &printOpenTypeValue;
    pVarName = varname;
+   ast_mutex_lock(&printlock);
    OOTRACEDBGB2("%s = {\n", pVarName);
    gIndentSpaces += 3;
 
@@ -72,6 +74,8 @@
    if (gIndentSpaces != 0) {
       OOTRACEDBGB1 ("ERROR: unbalanced structure\n");
    }
+   gIndentSpaces = 0;
+   ast_mutex_unlock(&printlock);
 }
 
 void indent ()




More information about the asterisk-commits mailing list