fixed mantis 336 - timer queue should have try / catch block
around call to user's expiration callback
This commit is contained in:
@@ -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 @@ timerQueue::~timerQueue ()
|
||||
}
|
||||
}
|
||||
|
||||
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,8 +127,15 @@ double timerQueue::process ( const epicsTime & currentTime )
|
||||
debugPrintf ( ( "%5u expired \"%s\" with error %f sec\n",
|
||||
N++, typeid ( this->pExpireTmr->notify ).name (),
|
||||
currentTime - this->pExpireTmr->exp ) );
|
||||
|
||||
expStat = pTmpNotify->expire ( currentTime );
|
||||
try {
|
||||
expStat = pTmpNotify->expire ( currentTime );
|
||||
}
|
||||
catch ( std::exception & except ) {
|
||||
printExceptMsg ( except.what (), typeid ( except ) );
|
||||
}
|
||||
catch ( ... ) {
|
||||
printExceptMsg ( "non-standard exception", typeid ( void ) );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user