timer queue should have try / catch block around call to user's expiration callback
Bug #541364 reported by
Jeff Hill
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
Wishlist
|
Jeff Hill |
Bug Description
if an exception occurs in the user's expiration callback
the library should catch it and print a diagnostic message,
the timer queue thread should continue to run, and the
timer queue thread should not be compromised by an
exception occurring in, and not caught by, user code
Original Mantis Bug: mantis-336
http://
To post a comment you must log in.
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\) ======= ======= ======= ======= ======= ======= ======= ======= ==== epicsmgr/ cvsroot/ epics/base/ src/libCom/ timer/timerPriv ate.h,v ******* ******* ******* ******* ******* ******* ******* ******* ******* *****/
Index: timerPrivate.h
=======
RCS file: /net/phoebus/
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; Notify ¬ify ); QueueNotify & notify; ======= ======= ======= ======= ======= ======= ======= ======= ==== epicsmgr/ cvsroot/ epics/base/ src/libCom/ timer/timerQueu e.cpp,v edSymbols
+
class timerQueue : public epicsTimerQueue {
public:
timerQueue ( epicsTimerQueue
@@ -103,7 +107,11 @@
epicsTimer
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/
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 epicsExportShar
#include "epicsGuard.h"
#include "timerPrivate.h"
+#include "errlog.h"
+
+const double timerQueue :: exceptMsgMinPeriod = 60.0 * 5.0; // seconds
epicsTimerQueu e::~epicsTimerQ ueue () {}
timerQueue: :timerQueue ( epicsTimerQueue Notify & 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 :: TimeStamp; TimeStamp = cur;
+ printExceptMsg ( const char * pName, const type_info & type )
+{
+ epicsTime cur = epicsTime :: getCurrent ();
+ double delay = cur - this->exceptMsg
+ if ( delay >= exceptMsgMinPeriod ) {
+ this->exceptMsg
+ 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 beca...