Comment 1 for bug 541364

Revision history for this message
Jeff Hill (johill-lanl) wrote :

I committed this patch

cvs diff -r R3-14-2_branch:yesterday -wb (in directory C:\hill\R3.14.dll_hell_fix\epics\base\src\libCom\timer\)
Index: timerPrivate.h
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/timer/timerPrivate.h,v
retrieving revision 1.30.2.5
retrieving revision 1.30.2.6
diff -u -b -w -b -r1.30.2.5 -r1.30.2.6
--- timerPrivate.h 23 Feb 2009 22:51:50 -0000 1.30.2.5
+++ timerPrivate.h 13 Mar 2009 17:23:06 -0000 1.30.2.6
@@ -8,7 +8,7 @@
 * in file LICENSE that is included with this distribution.
 \*************************************************************************/
 /*
- * $Id: timerPrivate.h,v 1.30.2.5 2009/02/23 22:51:50 anj Exp $
+ * $Id: timerPrivate.h,v 1.30.2.6 2009/03/13 17:23:06 jhill Exp $
  *
  * Author Jeffrey O. Hill
  * <email address hidden>
@@ -18,6 +18,8 @@
 #ifndef epicsTimerPrivate_h
 #define epicsTimerPrivate_h

+#include <typeinfo>
+
 #include "tsFreeList.h"
 #include "epicsSingleton.h"
 #include "tsDLList.h"
@@ -86,6 +88,8 @@
     friend class timerQueue;
 };

+using std :: type_info;
+
 class timerQueue : public epicsTimerQueue {
 public:
     timerQueue ( epicsTimerQueueNotify &notify );
@@ -103,7 +107,11 @@
     epicsTimerQueueNotify & notify;
     timer * pExpireTmr;
     epicsThreadId processThread;
+ epicsTime exceptMsgTimeStamp;
     bool cancelPending;
+ static const double exceptMsgMinPeriod;
+ void printExceptMsg ( const char * pName,
+ const type_info & type );
  timerQueue ( const timerQueue & );
     timerQueue & operator = ( const timerQueue & );
     friend class timer;
Index: timerQueue.cpp
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/libCom/timer/timerQueue.cpp,v
retrieving revision 1.22.2.1
retrieving revision 1.22.2.2
diff -u -b -w -b -r1.22.2.1 -r1.22.2.2
--- timerQueue.cpp 8 Oct 2004 15:12:19 -0000 1.22.2.1
+++ timerQueue.cpp 13 Mar 2009 17:23:07 -0000 1.22.2.2
@@ -19,12 +19,19 @@
 #define epicsExportSharedSymbols
 #include "epicsGuard.h"
 #include "timerPrivate.h"
+#include "errlog.h"
+
+const double timerQueue :: exceptMsgMinPeriod = 60.0 * 5.0; // seconds

 epicsTimerQueue::~epicsTimerQueue () {}

 timerQueue::timerQueue ( epicsTimerQueueNotify & notifyIn ) :
- notify ( notifyIn ), pExpireTmr ( 0 ),
- processThread ( 0 ), cancelPending ( false )
+ notify ( notifyIn ),
+ pExpireTmr ( 0 ),
+ processThread ( 0 ),
+ exceptMsgTimeStamp (
+ epicsTime :: getCurrent () - exceptMsgMinPeriod ),
+ cancelPending ( false )
 {
 }

@@ -36,6 +43,30 @@
     }
 }

+void timerQueue ::
+ printExceptMsg ( const char * pName, const type_info & type )
+{
+ epicsTime cur = epicsTime :: getCurrent ();
+ double delay = cur - this->exceptMsgTimeStamp;
+ if ( delay >= exceptMsgMinPeriod ) {
+ this->exceptMsgTimeStamp = cur;
+ char date[64];
+ cur.strftime ( date, sizeof ( date ),
+ "%a %b %d %Y %H:%M:%S.%f" );
+ // we dont touch the typeid for the timer expiration
+ // notify interface here because they might have
+ // destroyed the timer during its callback
+ errlogPrintf (
+ "timerQueue: Unexpected C++ exception "%s" "
+ "with type "%s" during timer expiration "
+ "callback at %s\n",
+ pName,
+ type.name (),
+ date );
+ errlogFlush ();
+ }
+}
+
 double timerQueue::process ( const epicsTime & currentTime )
 {
     epicsGuard < epicsMutex > guard ( this->mutex );
@@ -96,9 +127,16 @@
             debugPrintf ( ( "%5u expired "%s" with error %f sec\n",
                 N++, typeid ( this->pExpireTmr->notify ).name (),
                 currentTime - this->pExpireTmr->exp ) );
-
+ try {
             expStat = pTmpNotify->expire ( currentTime );
         }
+ catch ( std::exception & except ) {
+ printExceptMsg ( except.what (), typeid ( except ) );
+ }
+ catch ( ... ) {
+ printExceptMsg ( "non-standard exception", typeid ( void ) );
+ }
+ }

         //
         // only restart if they didnt cancel() the timer