[asterisk-commits] may: branch 10 r343445 - in /branches/10: ./ addons/ooh323c/src/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 4 10:11:55 CDT 2011


Author: may
Date: Fri Nov  4 10:11:52 2011
New Revision: 343445

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=343445
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.
........

Merged revisions 343281 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/addons/ooh323c/src/dlist.c
    branches/10/addons/ooh323c/src/dlist.h
    branches/10/addons/ooh323c/src/ooGkClient.c
    branches/10/addons/ooh323c/src/ooTimer.c
    branches/10/addons/ooh323c/src/ooq931.c
    branches/10/addons/ooh323c/src/printHandler.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/addons/ooh323c/src/dlist.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/dlist.c?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/dlist.c (original)
+++ branches/10/addons/ooh323c/src/dlist.c Fri Nov  4 10:11:52 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/10/addons/ooh323c/src/dlist.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/dlist.h?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/dlist.h (original)
+++ branches/10/addons/ooh323c/src/dlist.h Fri Nov  4 10:11:52 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/10/addons/ooh323c/src/ooGkClient.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/ooGkClient.c?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/ooGkClient.c (original)
+++ branches/10/addons/ooh323c/src/ooGkClient.c Fri Nov  4 10:11:52 2011
@@ -365,7 +365,7 @@
 
 int ooGkClientReceive(ooGkClient *pGkClient)
 {
-   ASN1OCTET recvBuf[1024];
+   ASN1OCTET recvBuf[ASN_K_ENCBUFSIZ];
    int recvLen;
    char remoteHost[32];
    int iFromPort=0;
@@ -376,7 +376,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)
    {
@@ -859,7 +859,6 @@
          memFreePtr(&pGkClient->ctxt, pTimer->cbData);
          ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
          OOTRACEDBGA1("Deleted GRQ Timer.\n");
-         break;
       }
    }
 
@@ -1064,7 +1063,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;
@@ -1137,6 +1136,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,
@@ -1289,7 +1290,6 @@
          memFreePtr(&pGkClient->ctxt, pTimer->cbData);
          ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
          OOTRACEDBGA1("Deleted RRQ Timer.\n");
-         break;
       }
    }
 

Modified: branches/10/addons/ooh323c/src/ooTimer.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/ooTimer.c?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/ooTimer.c (original)
+++ branches/10/addons/ooh323c/src/ooTimer.c Fri Nov  4 10:11:52 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/10/addons/ooh323c/src/ooq931.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/ooq931.c?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/ooq931.c (original)
+++ branches/10/addons/ooh323c/src/ooq931.c Fri Nov  4 10:11:52 2011
@@ -512,7 +512,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/10/addons/ooh323c/src/printHandler.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/addons/ooh323c/src/printHandler.c?view=diff&rev=343445&r1=343444&r2=343445
==============================================================================
--- branches/10/addons/ooh323c/src/printHandler.c (original)
+++ branches/10/addons/ooh323c/src/printHandler.c Fri Nov  4 10:11:52 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