[asterisk-commits] may: branch may/chan_ooh323_evo r343489 - in /team/may/chan_ooh323_evo: addon...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 5 17:58:04 CDT 2011
Author: may
Date: Sat Nov 5 17:57:59 2011
New Revision: 343489
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=343489
Log:
introduce addition memory context from timer operation in gk client
(this was made for memleak finding, this is done in the trunk
already but could be useful in the future)
fix memleaks in gkclient, timer and dlist codes.
fix unbalanced in printHandler (already in the trunk)
made reentrancy_lock inline for memleak finding
Modified:
team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.c
team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.h
team/may/chan_ooh323_evo/addons/ooh323c/src/memheap-addon.h
team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.c
team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.h
team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.c
team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.h
team/may/chan_ooh323_evo/addons/ooh323c/src/ooTimer.c
team/may/chan_ooh323_evo/addons/ooh323c/src/ooasn1.h
team/may/chan_ooh323_evo/addons/ooh323c/src/oochannels.c
team/may/chan_ooh323_evo/addons/ooh323c/src/printHandler.c
team/may/chan_ooh323_evo/include/asterisk/lock.h
team/may/chan_ooh323_evo/main/lock.c
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.c Sat Nov 5 17:57:59 2011
@@ -31,7 +31,7 @@
DListNode* dListAppend (OOCTXT* pctxt, DList* pList, void* pData)
{
DListNode* pListNode = (DListNode*)
- memAlloc (pctxt, sizeof(DListNode));
+ memAllocZ (pctxt, sizeof(DListNode));
if (0 != pListNode) {
pListNode->data = pData;
@@ -135,7 +135,7 @@
pList->count--;
}
-void dListFindAndRemove(DList* pList, void *data)
+void dListFindAndRemove(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: team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.h (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/dlist.h Sat Nov 5 17:57:59 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: team/may/chan_ooh323_evo/addons/ooh323c/src/memheap-addon.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/memheap-addon.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/memheap-addon.h (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/memheap-addon.h Sat Nov 5 17:57:59 2011
@@ -335,3 +335,256 @@
ast_mutex_unlock(&pMemHeap->pLock);
return (mem_p);
}
+
+static inline void* memHeapAllocZX (void** ppvMemHeap, int nbytes, const char *file, int lineno, const char *func)
+{
+ OSMemHeap* pMemHeap;
+ OSMemLink* pMemLink, **ppMemLink;
+ OSMemBlk* pMemBlk = 0;
+ void* mem_p = NULL;
+ unsigned remUnits;
+ ASN1UINT nunits;
+
+ if (ppvMemHeap == 0)
+ return 0;
+
+ if (*ppvMemHeap == 0)
+ if (memHeapCreate (ppvMemHeap) != ASN_OK)
+ return 0;
+
+ /* Round number of bytes to nearest 8-byte boundary */
+
+ nunits = (((unsigned)(nbytes + 7)) >> 3);
+
+ pMemHeap = (OSMemHeap*) *ppvMemHeap;
+ ast_mutex_lock(&pMemHeap->pLock);
+ ppMemLink = &pMemHeap->phead;
+
+ /* if size is greater than 2**19, then allocate as RAW block */
+
+ if (nunits > (1<<16) - 2) {
+ void *data;
+
+ /* allocate raw block */
+
+#ifdef __AST_DEBUG_MALLOC
+ data = __ast_malloc(nbytes, file, lineno, func);
+#else
+ data = ast_calloc(nbytes, 1);
+#endif
+ if (data == NULL) {
+ return NULL;
+ }
+ pMemLink = memHeapAddBlock (ppMemLink, data, RTMEMMALLOC | RTMEMRAW);
+ if (pMemLink == 0) {
+ free (data);
+ return NULL;
+ }
+ /* save size of the RAW memory block behind the pMemLink */
+ *(int*)(((char*)pMemLink) + sizeof (OSMemLink)) = nbytes;
+ ast_mutex_unlock(&pMemHeap->pLock);
+ memset (data, 0, nbytes);
+ return data;
+ }
+
+ RTMEMDIAG2 ("memHeapAlloc: adjusted nbytes = %d\n", nbytes);
+
+ /* Try to allocate a slot from an existing block on the list */
+
+ for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnext) {
+ if (pMemLink->blockType & RTMEMRAW) continue;
+ else pMemBlk = (OSMemBlk*) pMemLink->pMemBlk;
+
+ remUnits = pMemBlk->nunits - pMemBlk->free_x;
+
+ if ((unsigned)(nunits + 1) <= remUnits) {
+ OSMemElemDescr* pElem = (OSMemElemDescr*)
+ &pMemBlk->data [((ASN1UINT)pMemBlk->free_x) * 8u];
+ OSMemElemDescr* pPrevElem;
+
+ RTMEMDIAG1 ("memHeapAlloc: found existing slot..\n");
+
+ /* if block is clean, set some vars in heap */
+ if (pMemBlk->free_x == 0) {
+ pMemHeap->freeUnits -= pMemBlk->nunits;
+ pMemHeap->freeBlocks--;
+ }
+
+ pElem_flags (pElem) = 0;
+ if (pMemBlk->lastElemOff != 0)
+ pElem_prevOff (pElem) =
+ (ASN1USINT)(pMemBlk->free_x - pMemBlk->lastElemOff + 1);
+ else
+ pElem_prevOff (pElem) = 0;
+
+ pPrevElem = GET_LAST_ELEM (pMemBlk);
+ if (pPrevElem != 0)
+ CLEAR_LAST (pPrevElem);
+
+ pElem_nunits (pElem) = (ASN1USINT)nunits;
+ pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data);
+ pMemBlk->lastElemOff = (ASN1USINT)(pMemBlk->free_x + 1);
+
+ mem_p = (void*) (pElem_data (pElem));
+
+ /* sizeof (OSMemElemDescr) == 1 unit */
+ pMemBlk->free_x += nunits + 1;
+
+ SET_LAST_ELEM (pMemBlk, pElem);
+
+ FILLNEWMEM (mem_p, nunits * 8u);
+ TRACEMEMELEM(pMemBlk, pElem, "Allocated");
+ CHECKMEMELEM (pMemBlk, pElem);
+ CHECKMEMBLOCK (pMemHeap, pMemBlk);
+ break;
+ }
+ }
+
+ /* If not successful, look for empty elements in existing blocks */
+
+ if (0 == mem_p) {
+ for (pMemLink = *ppMemLink; pMemLink != 0; pMemLink = pMemLink->pnext) {
+ if (pMemLink->blockType & RTMEMRAW) continue;
+
+ pMemBlk = (OSMemBlk*) pMemLink->pMemBlk;
+
+ if (nunits <= (ASN1UINT)pMemBlk->freeMem) {
+ OSMemElemDescr* pElem = GET_FREE_ELEM(pMemBlk), *pPrevFree = 0;
+
+ RTMEMDIAG2
+ ("memHeapAlloc: try to reuse empty elems in pMemBlk = 0x%x...\n",
+ pMemBlk);
+
+ while (pElem != 0) {
+ if (ISFREE (pElem)) {
+ if (nunits <= (ASN1UINT)pElem_nunits (pElem)) {
+ RTMEMDIAG3
+ ("memHeapAlloc: "
+ "found an exisiting free element 0x%x, size %d\n",
+ pElem, (pElem_nunits (pElem) * 8u));
+
+ if (pMemBlk->freeElemOff ==
+ QOFFSETOF (pElem, pMemBlk->data) + 1)
+ {
+
+ /* modify the pMemBlk->freeElemOff value if necsry */
+
+ OSMemElemDescr* nextFree = GET_NEXT_FREE (pElem);
+ FORCE_SET_FREE_ELEM (pMemBlk, nextFree);
+ }
+ else if (pPrevFree != 0) {
+ OSMemElemDescr* pNextFree = GET_NEXT_FREE (pElem);
+ if (pNextFree != 0)
+ pElem_nextFreeOff (pPrevFree) = QOFFSETOF (pNextFree,
+ pPrevFree);
+ else
+ pElem_nextFreeOff (pPrevFree) = 0;
+ }
+
+ CLEAR_FREE (pElem);
+
+ /* set beginOff value */
+
+ pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data);
+
+ pMemBlk->freeMem -= pElem_nunits (pElem);
+
+ CHECKMEMELEM (pMemBlk, pElem);
+ CHECKMEMBLOCK (pMemHeap, pMemBlk);
+
+ mem_p = memHeapRealloc
+ (ppvMemHeap, pElem_data (pElem), nunits * 8u);
+ if (mem_p != 0) {
+ FILLNEWMEM (mem_p, nunits * 8u);
+ TRACEMEMELEM(pMemBlk, pElem, "Allocated");
+ }
+ break;
+ }
+ }
+ pPrevFree = pElem;
+ pElem = GET_NEXT_FREE (pElem);
+ }
+ if (mem_p != 0) break;
+ }
+ }
+ }
+
+ /* If not successful, malloc a new block and alloc from it */
+
+ if (!mem_p) {
+ ASN1UINT allocSize, dataUnits;
+ ASN1OCTET* pmem;
+ register ASN1UINT defBlkSize = pMemHeap->defBlkSize;
+
+ RTMEMDIAG1 ("memHeapAlloc: alloc block..\n");
+
+ allocSize = (ASN1UINT) ((((ASN1UINT)nunits) * 8u) +
+ sizeof (OSMemBlk) + sizeof_OSMemElemDescr);
+ allocSize = (ASN1UINT) (allocSize < defBlkSize) ? defBlkSize :
+ ((allocSize + defBlkSize - 1) / defBlkSize * defBlkSize);
+ dataUnits = (ASN1UINT)((allocSize - sizeof (OSMemBlk)) >> 3u);
+ if (dataUnits >= (1u<<16)) {
+ dataUnits = (ASN1UINT)((1u<<16) - 1);
+ allocSize = (ASN1UINT)
+ ((((ASN1UINT)dataUnits) * 8u) + sizeof (OSMemBlk));
+ }
+
+#ifdef __AST_DEBUG_MALLOC
+ pmem = (ASN1OCTET*) __ast_malloc (allocSize + sizeof (OSMemLink), file, lineno, func);
+#else
+ pmem = (ASN1OCTET*) ast_calloc (allocSize + sizeof (OSMemLink), 1);
+#endif
+ if (0 != pmem) {
+ OSMemElemDescr* pElem;
+
+ pMemBlk = (OSMemBlk*) (pmem + sizeof (OSMemLink));
+ pElem = (OSMemElemDescr*)&pMemBlk->data[0];
+
+ mem_p = (void*) pElem_data (pElem);
+ pElem_nunits (pElem) = (ASN1USINT)nunits;
+ pElem_flags (pElem) = 0;
+ pElem_prevOff (pElem) = 0;
+ pElem_beginOff (pElem) = QOFFSETOF (pElem, pMemBlk->data);
+
+ /* sizeof (OSMemElemDescr) == 1 unit */
+ pMemBlk->free_x = (ASN1USINT)(nunits + 1);
+
+ pMemBlk->freeMem = 0;
+ pMemBlk->nunits = (ASN1USINT)dataUnits;
+ SET_LAST_ELEM (pMemBlk, pElem);
+ pMemBlk->freeElemOff = 0;
+ pMemBlk->nsaved = 0;
+
+ if (memHeapAddBlock (ppMemLink, pMemBlk, RTMEMSTD | RTMEMLINK) == 0)
+ {
+ free (pmem);
+ ast_mutex_unlock(&pMemHeap->pLock);
+ return NULL;
+ }
+
+ /* set vars in heap */
+ pMemHeap->usedUnits += dataUnits;
+ pMemHeap->usedBlocks++;
+
+ FILLNEWMEM (mem_p, nunits * 8u);
+ TRACEMEMELEM(pMemBlk, pElem, "Allocated");
+ CHECKMEMELEM (pMemBlk, pElem);
+ CHECKMEMBLOCK (pMemHeap, pMemBlk);
+ }
+ else {
+ ast_mutex_unlock(&pMemHeap->pLock);
+ return NULL;
+ }
+ }
+ RTMEMDIAG2 ("memHeapAlloc: pMemBlk = 0x%x\n", pMemBlk);
+ RTMEMDIAG2 ("memHeapAlloc: pMemBlk->free_x = %d\n", pMemBlk->free_x);
+ RTMEMDIAG2 ("memHeapAlloc: pMemBlk->size = %d\n",
+ pMemBlk->nunits * 8u);
+ RTMEMDIAG2 ("memHeapAlloc: mem_p = 0x%x\n", mem_p);
+ RTMEMDIAG2 ("memHeapAlloc: sizeof (short) = %d\n", sizeof(short));
+
+ ast_mutex_unlock(&pMemHeap->pLock);
+ memset (mem_p, 0, nbytes);
+ return (mem_p);
+}
+
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.c Sat Nov 5 17:57:59 2011
@@ -131,12 +131,12 @@
}
}
-void* memHeapAllocZ (void** ppvMemHeap, int nbytes)
+/* void* memHeapAllocZ (void** ppvMemHeap, int nbytes)
{
void* ptr = memHeapAlloc (ppvMemHeap, nbytes);
if (0 != ptr) memset (ptr, 0, nbytes);
return ptr;
-}
+} */
void memHeapFreePtr (void** ppvMemHeap, void* mem_p)
{
@@ -824,9 +824,10 @@
}
if ((*ppMemHeap)->flags & RT_MH_FREEHEAPDESC) {
- ast_mutex_destroy(&pMemHeap->pLock);
+ ast_mutex_destroy(&pMemHeap->pLock);
free (*ppMemHeap);
}
+
*ppMemHeap = 0;
}
}
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.h (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/memheap.h Sat Nov 5 17:57:59 2011
@@ -80,7 +80,8 @@
#define memHeapAlloc(a,b) \
memHeapAllocX(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
-
+#define memHeapAllocZ(a,b) \
+ memHeapAllocZX(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#include "memheap-addon.h"
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.c Sat Nov 5 17:57:59 2011
@@ -53,7 +53,6 @@
static OOCTXT* ooPrintPCTXT = NULL;
-
int ooGkClientInit(enum RasGatekeeperMode eGkMode,
char *szGkAddr, int iGkPort )
{
@@ -72,6 +71,7 @@
gH323ep.gkClient = pGkClient;
initContext(&(pGkClient->ctxt));
initContext(&(pGkClient->msgCtxt));
+ initContext(&(pGkClient->ttxt));
pGkClient->rrqRetries = 0;
pGkClient->grqRetries = 0;
@@ -740,7 +740,7 @@
}
OOTRACEINFO1("Sent GRQ message\n");
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n");
@@ -750,12 +750,12 @@
}
cbData->timerType = OO_GRQ_TIMER;
cbData->pGkClient = pGkClient;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientGRQTimerExpired, pGkClient->grqTimeout,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock);
return OO_FAILED;
@@ -780,8 +780,8 @@
pTimer = (OOTimer*)pNode->data;
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_GRQ_TIMER)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted GRQ Timer.\n");
break;
}
@@ -890,8 +890,8 @@
pTimer = (OOTimer*)pNode->data;
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_GRQ_TIMER)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted GRQ Timer.\n");
}
}
@@ -1109,7 +1109,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;
@@ -1141,7 +1141,7 @@
OOTRACEINFO1("Sent RRQ message \n");
/* Start RRQ Timer */
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory to RRQ timer callback\n");
@@ -1151,12 +1151,12 @@
}
cbData->timerType = OO_RRQ_TIMER;
cbData->pGkClient = pGkClient;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientRRQTimerExpired, pGkClient->rrqTimeout,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock);
return OO_FAILED;
@@ -1183,6 +1183,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,
@@ -1264,7 +1266,7 @@
}
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory for Regisration timer."
@@ -1274,12 +1276,12 @@
}
cbData->timerType = OO_REG_TIMER;
cbData->pGkClient = pGkClient;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientREGTimerExpired, regTTL,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create REG timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
pGkClient->state = GkClientFailed;
return OO_FAILED;
}
@@ -1306,8 +1308,8 @@
pTimer = (OOTimer*)pNode->data;
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted RRQ Timer.\n");
}
}
@@ -1332,8 +1334,8 @@
pTimer = (OOTimer*)pNode->data;
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted RRQ Timer.\n");
break;
}
@@ -1585,13 +1587,13 @@
pNode = dListFindByIndex(&pGkClient->timerList, x);
pTimer = (OOTimer*)pNode->data;
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_RRQ_TIMER) {
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted RRQ Timer.\n");
}
if(((ooGkClientTimerCb*)pTimer->cbData)->timerType & OO_REG_TIMER) {
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
OOTRACEDBGA1("Deleted REG Timer.\n");
}
}
@@ -1926,7 +1928,7 @@
/* Add ARQ timer */
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory for Regisration timer."
@@ -1938,12 +1940,12 @@
cbData->timerType = OO_ARQ_TIMER;
cbData->pGkClient = pGkClient;
cbData->pAdmInfo = pCallAdmInfo;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientARQTimerExpired, pGkClient->arqTimeout,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create ARQ timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock);
return OO_FAILED;
@@ -2041,8 +2043,8 @@
if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo ==
pCallAdmInfo)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList,
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList,
pTimer);
OOTRACEDBGA1("Deleted ARQ Timer.\n");
break;
@@ -2124,8 +2126,8 @@
if(((ooGkClientTimerCb*)pTimer->cbData)->pAdmInfo ==
pCallAdmInfo)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList,
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList,
pTimer);
OOTRACEDBGA1("Deleted ARQ Timer.\n");
break;
@@ -2621,6 +2623,7 @@
if(pGkClient->rrqRetries < OO_MAX_RRQ_RETRIES)
{
+ memFreePtr(&pGkClient->ttxt, cbData);
ret = ooGkClientSendRRQ(pGkClient, 0);
if(ret != OO_OK)
{
@@ -2629,10 +2632,9 @@
return OO_FAILED;
}
pGkClient->rrqRetries++;
- memFreePtr(&pGkClient->ctxt, cbData);
return OO_OK;
}
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
OOTRACEERR1("Error:Failed to register with gatekeeper\n");
pGkClient->state = GkClientUnregistered;
@@ -2643,7 +2645,7 @@
ast_mutex_lock(&pGkClient->Lock);
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory to RRQ timer callback\n");
@@ -2652,22 +2654,22 @@
return OO_FAILED;
}
+
+/* clear rrq count for re-register after regTimeout */
+ pGkClient->rrqRetries = 0;
cbData->timerType = OO_RRQ_TIMER;
cbData->pGkClient = pGkClient;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientRRQTimerExpired, pGkClient->regTimeout,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
- pGkClient->state = GkClientFailed;
- ast_mutex_unlock(&pGkClient->Lock);
- return OO_FAILED;
- }
-
-/* clear rrq count for re-register after regTimeout */
- pGkClient->rrqRetries = 0;
+ memFreePtr(&pGkClient->ttxt, cbData);
+ pGkClient->state = GkClientFailed;
+ ast_mutex_unlock(&pGkClient->Lock);
+ return OO_FAILED;
+ }
ast_mutex_unlock(&pGkClient->Lock);
@@ -2682,7 +2684,7 @@
OOTRACEDBGA1("Gatekeeper client GRQ timer expired.\n");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
if(pGkClient->grqRetries < OO_MAX_GRQ_RETRIES)
{
@@ -2703,7 +2705,7 @@
ast_mutex_lock(&pGkClient->Lock);
cbData = (ooGkClientTimerCb*) memAlloc
- (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+ (&pGkClient->ttxt, sizeof(ooGkClientTimerCb));
if(!cbData)
{
OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n");
@@ -2713,12 +2715,12 @@
}
cbData->timerType = OO_GRQ_TIMER;
cbData->pGkClient = pGkClient;
- if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+ if(!ooTimerCreate(&pGkClient->ttxt, &pGkClient->timerList,
&ooGkClientGRQTimerExpired, pGkClient->grqTimeout,
cbData, FALSE))
{
OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
pGkClient->state = GkClientFailed;
ast_mutex_unlock(&pGkClient->Lock);
return OO_FAILED;
@@ -2738,7 +2740,7 @@
ooGkClientTimerCb *cbData = (ooGkClientTimerCb*)pdata;
ooGkClient *pGkClient = cbData->pGkClient;
OOTRACEDBGA1("Gatekeeper client additive registration timer expired\n");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
ret = ooGkClientSendRRQ(pGkClient, TRUE);
if(ret != OO_OK)
{
@@ -2757,7 +2759,7 @@
RasCallAdmissionInfo *pAdmInfo = cbData->pAdmInfo;
OOTRACEDBGA1("Gatekeeper client ARQ timer expired.\n");
- memFreePtr(&pGkClient->ctxt, cbData);
+ memFreePtr(&pGkClient->ttxt, cbData);
if(!pAdmInfo)
return OO_OK;
@@ -2812,8 +2814,8 @@
if(cbData->timerType & OO_ARQ_TIMER &&
cbData->pAdmInfo->call->callReference == call->callReference)
{
- memFreePtr(&pGkClient->ctxt, pTimer->cbData);
- ooTimerDelete(&pGkClient->ctxt, &pGkClient->timerList, pTimer);
+ memFreePtr(&pGkClient->ttxt, pTimer->cbData);
+ ooTimerDelete(&pGkClient->ttxt, &pGkClient->timerList, pTimer);
break;
}
}
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.h (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/ooGkClient.h Sat Nov 5 17:57:59 2011
@@ -179,6 +179,7 @@
ASN1BOOL discoveryComplete;
OOCTXT ctxt;
OOCTXT msgCtxt;
+ OOCTXT ttxt;
OOSOCKET rasSocket;
int localRASPort;
char localRASIP[2+8*4+7];
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/ooTimer.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/ooTimer.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/ooTimer.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/ooTimer.c Sat Nov 5 17:57:59 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: team/may/chan_ooh323_evo/addons/ooh323c/src/ooasn1.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/ooasn1.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/ooasn1.h (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/ooasn1.h Sat Nov 5 17:57:59 2011
@@ -924,7 +924,7 @@
EXTERN void memHeapAddRef (void** ppvMemHeap);
/* EXTERN void* memHeapAlloc (void** ppvMemHeap, int nbytes);*/
-EXTERN void* memHeapAllocZ (void** ppvMemHeap, int nbytes);
+/* EXTERN void* memHeapAllocZ (void** ppvMemHeap, int nbytes); */
EXTERN int memHeapCheckPtr (void** ppvMemHeap, void* mem_p);
EXTERN int memHeapCreate (void** ppvMemHeap);
EXTERN void memHeapFreeAll (void** ppvMemHeap);
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/oochannels.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/oochannels.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/oochannels.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/oochannels.c Sat Nov 5 17:57:59 2011
@@ -590,7 +590,7 @@
/* Process gatekeeper client timers */
if(gH323ep.gkClient)
{
- ooTimerFireExpired(&gH323ep.gkClient->ctxt,
+ ooTimerFireExpired(&gH323ep.gkClient->ttxt,
&gH323ep.gkClient->timerList);
if(ooTimerNextTimeout(&gH323ep.gkClient->timerList, &toNext))
{
Modified: team/may/chan_ooh323_evo/addons/ooh323c/src/printHandler.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/addons/ooh323c/src/printHandler.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/addons/ooh323c/src/printHandler.c (original)
+++ team/may/chan_ooh323_evo/addons/ooh323c/src/printHandler.c Sat Nov 5 17:57:59 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 ()
Modified: team/may/chan_ooh323_evo/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/include/asterisk/lock.h?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/include/asterisk/lock.h (original)
+++ team/may/chan_ooh323_evo/include/asterisk/lock.h Sat Nov 5 17:57:59 2011
@@ -435,15 +435,23 @@
{
pthread_mutex_unlock(<->reentr_mutex);
}
-
-static inline void ast_reentrancy_init(struct ast_lock_track **plt)
+/* #define ast_reentrancy_init(a) \
+ ast_reentrancy_init_x(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) */
+
+static inline void ast_reentrancy_init(struct ast_lock_track **plt, const char *file, int lineno, const char *func)
{
int i;
pthread_mutexattr_t reentr_attr;
struct ast_lock_track *lt = *plt;
if (!lt) {
+#ifdef __AST_DEBUG_MALLOC
+ lt = *plt = (struct ast_lock_track *)
+ __ast_malloc(sizeof(*lt), file, lineno, func);
+ memset(lt, 0, sizeof(*lt));
+#else
lt = *plt = (struct ast_lock_track *) calloc(1, sizeof(*lt));
+#endif
}
for (i = 0; i < AST_MAX_REENTRANCY; i++) {
Modified: team/may/chan_ooh323_evo/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/main/lock.c?view=diff&rev=343489&r1=343488&r2=343489
==============================================================================
--- team/may/chan_ooh323_evo/main/lock.c (original)
+++ team/may/chan_ooh323_evo/main/lock.c Sat Nov 5 17:57:59 2011
@@ -63,7 +63,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if ((t->tracking = tracking)) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
#endif /* DEBUG_THREADS */
@@ -99,7 +99,7 @@
#endif
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -146,6 +146,8 @@
memset(<->backtrace[0], 0, sizeof(lt->backtrace[0]));
#endif
ast_reentrancy_unlock(lt);
+ }
+ if (t->track) {
delete_reentrancy_cs(&t->track);
}
#endif /* DEBUG_THREADS */
@@ -181,7 +183,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -313,7 +315,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -385,7 +387,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -495,7 +497,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -603,7 +605,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
lt = t->track;
@@ -701,7 +703,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if ((t->tracking = tracking)) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, lineno, func);
}
#endif /* DEBUG_THREADS */
@@ -752,6 +754,8 @@
memset(<->backtrace[0], 0, sizeof(lt->backtrace[0]));
#endif
ast_reentrancy_unlock(lt);
+ }
+ if (t->track) {
delete_reentrancy_cs(&t->track);
}
#endif /* DEBUG_THREADS */
@@ -786,7 +790,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -872,7 +876,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -991,7 +995,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -1114,7 +1118,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -1217,7 +1221,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -1323,7 +1327,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
@@ -1393,7 +1397,7 @@
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
if (t->tracking && !t->track) {
- ast_reentrancy_init(&t->track);
+ ast_reentrancy_init(&t->track, filename, line, func);
}
lt = t->track;
More information about the asterisk-commits
mailing list