< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] SipStack statistics


> This change is checked in.
Thanks a lot.

One more question ;) 
What about cleaning statistics? As I see the
statistics will never be cleaned...

As I understand it could be reached by attached
patches.

Regards,
Volodymyr!




       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/
--- StatisticsManager.orig.hxx	2007-10-17 10:15:35.000000000 +0300
+++ StatisticsManager.hxx	2007-10-17 10:18:39.000000000 +0300
@@ -38,6 +38,11 @@
       {
          mExternalHandler = handler;
       }
+      // Set flag to clear statistics after next poll
+      void clear()
+      {
+      	mClear = true;
+      }
 
    private:
       friend class TransactionState;
@@ -45,11 +50,14 @@
       bool received(SipMessage* msg);
 
       void poll(); // force an update
+      void doClear(); // clears statistics
 
       SipStack& mStack;
       UInt64 mInterval;
       UInt64 mNextPoll;
 
+      bool   mClear;
+
       ExternalStatsHandler *mExternalHandler;
 };
 
--- StatisticsManager.orig.cxx	2007-10-17 10:15:43.000000000 +0300
+++ StatisticsManager.cxx	2007-10-17 10:22:16.000000000 +0300
@@ -18,6 +18,7 @@
      mStack(stack),
      mInterval(intervalSecs*1000),
      mNextPoll(Timer::getTimeMs() + mInterval),
+     mClear(false),
      mExternalHandler(NULL)
 {}
 
@@ -44,6 +45,12 @@
    bool postToStack = true;
    StatisticsMessage msg(appStats);
 
+   if (mClear)
+   {
+       mClear = false;
+       doClear();
+   }
+
    if( mExternalHandler )
    {
       postToStack = (*mExternalHandler)(msg);
@@ -128,6 +135,20 @@
    return false;
 }
 
+void
+StatisticsManager::doClear()
+{
+   memset(responsesByCode, 0, sizeof(responsesByCode));
+   memset(requestsSentByMethod, 0, sizeof(requestsSentByMethod));
+   memset(requestsRetransmittedByMethod, 0, sizeof(requestsRetransmittedByMethod));
+   memset(requestsReceivedByMethod, 0, sizeof(requestsReceivedByMethod));
+   memset(responsesSentByMethod, 0, sizeof(responsesSentByMethod));
+   memset(responsesRetransmittedByMethod, 0, sizeof(responsesRetransmittedByMethod));
+   memset(responsesReceivedByMethod, 0, sizeof(responsesReceivedByMethod));
+   memset(responsesSentByMethodByCode, 0, sizeof(responsesSentByMethodByCode));
+   memset(responsesRetransmittedByMethodByCode, 0, sizeof(responsesRetransmittedByMethodByCode));
+   memset(responsesReceivedByMethodByCode, 0, sizeof(responsesReceivedByMethodByCode));
+}
 /* ====================================================================
  * The Vovida Software License, Version 1.0 
  *