Dale R. Worley wrote:
On Fri, 2007-03-02 at 19:40 +0100, [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
I have a problem with unitializing sipxtapi that occurs maybe 5% of the
time. It crashes in OsTimerTask.
Is sipXtapi's OsTimerTask the same as the one in the main sipX? There
have been a lot of fixes to OsTimer over the last year.
Dale
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/
Alexander Chemeris merged all available sipxportlib revisions into
sipxtapi branch. Sipxtacklib isn't fully merged yet.
The problem isn't in OsTimerTask, but in SipRefreshMgr. I attached a
patch that solves the problem.
Timers (+messages) that got fired were deleted but timers that werent
fired because sipxreinitialize or uninitialize was called werent
deleted. This patch puts all new timers into a UtlHashbag, and removes
them from it once they fire.
From what I have seen in SipRefreshManager.h it seems SipRefreshMgr
will be replaced so this patch should be sufficient.
Jaroslav Libak
diff -ru old/sipXtackLib/include/net/SipRefreshMgr.h
new/sipXtackLib/include/net/SipRefreshMgr.h
--- old/sipXtackLib/include/net/SipRefreshMgr.h Fri Mar 2 20:12:03 2007
+++ new/sipXtackLib/include/net/SipRefreshMgr.h Fri Mar 2 19:56:02 2007
@@ -138,12 +138,7 @@
void dumpMessageLists(UtlString& results) ;
//:Appends the message contents of both the mRegisterList and
// mSubscribeList
-
- OsTimer* getTimer()
- {
- return mpTimer;
- }
-
+
virtual ~SipRefreshMgr();
virtual UtlBoolean handleMessage( OsMsg& eventMessage );
@@ -311,7 +306,7 @@
int mUdpPort;
int mRestartCount;
UtlRandom mRandomNumGenerator ;
- OsTimer* mpTimer;
+ UtlHashBag mTimerBag;
};
#endif // SIPREFRESHMGR_H
diff -ru old/sipXtackLib/src/net/SipRefreshMgr.cpp
new/sipXtackLib/src/net/SipRefreshMgr.cpp
--- old/sipXtackLib/src/net/SipRefreshMgr.cpp Fri Mar 2 20:11:21 2007
+++ new/sipXtackLib/src/net/SipRefreshMgr.cpp Fri Mar 2 19:56:22 2007
@@ -62,8 +62,7 @@
mIsStarted(FALSE),
mObserverMutex(OsRWMutex::Q_FIFO),
mUAReadyMutex(OsRWMutex::Q_FIFO),
- mMyUserAgent(NULL),
- mpTimer(NULL)
+ mMyUserAgent(NULL)
{
}
@@ -83,6 +82,17 @@
mMessageObservers.remove(pObserver) ;
delete pObserver ;
}
+
+ // delete all unfired timers and their SipMessages
+ UtlHashBagIterator timerIterator(mTimerBag) ;
+ while (OsTimer* pTimer = (OsTimer*) timerIterator())
+ {
+ SipMessage *pMessage = (SipMessage *)pTimer->getUserData();
+ // get rid of them
+ delete pMessage;
+ delete pTimer;
+ }
+ mTimerBag.removeAll();
}
/*===================================================================*/
@@ -799,8 +809,8 @@
// Make a copy for the timer
SipMessage* timerRegisterMessage = new SipMessage(*request);
- OsTimer* timer = new OsTimer(&mIncomingQ, (int)timerRegisterMessage);
- mpTimer = timer;
+ OsTimer* timer = new OsTimer(&mIncomingQ, (int)timerRegisterMessage);
+ mTimerBag.insert(timer);
int maxSipTransactionTimeSecs =
(mMyUserAgent->getSipStateTransactionTimeout()/1000);
@@ -1443,6 +1453,8 @@
if ( timer )
{
+ // remove timer from mTimerBag
+ mTimerBag.removeReference(timer);
delete timer;
timer = NULL;
}
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/