libcom: Make EPICS_ABORT_ON_ASSERT affect cantProceed
EPICS_ABORT_ON_ASSERT was introduced to kill the entire IOC instead of suspending an individual thread on assert failure. This behavior, however, was not implemented for cantProceed, which left most of the epicsMustBlah APIs with the suspention behavior (except for a couple APIs that called assert() instead).
This commit is contained in:
1 parent
9e4b366ee8
commit
7f87a839f9
3 files changed
+24
-12
No files matched your search
@@ -15,6 +15,7 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "errlog.h"
|
||||
#include "envDefs.h"
|
||||
#include "cantProceed.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsStackTrace.h"
|
||||
@@ -53,20 +54,30 @@ LIBCOM_API void * mallocMustSucceed(size_t size, const char *msg)
|
||||
|
||||
LIBCOM_API void cantProceed(const char *msg, ...)
|
||||
{
|
||||
int shouldAbort = 0;
|
||||
va_list pvar;
|
||||
va_start(pvar, msg);
|
||||
if (msg)
|
||||
errlogVprintf(msg, pvar);
|
||||
va_end(pvar);
|
||||
|
||||
errlogPrintf(ANSI_RED("CRITICAL ERROR") " Thread %s (%p) can't proceed, suspending.\n",
|
||||
epicsThreadGetNameSelf(), epicsThreadGetIdSelf());
|
||||
envGetBoolConfigParam(&EPICS_ABORT_ON_ASSERT, &shouldAbort);
|
||||
|
||||
errlogPrintf(ANSI_RED("CRITICAL ERROR") " Thread %s (%p) can't proceed, %s.\n",
|
||||
epicsThreadGetNameSelf(), epicsThreadGetIdSelf(), shouldAbort ? "aborting" : "suspending");
|
||||
|
||||
epicsStackTrace();
|
||||
|
||||
errlogFlush();
|
||||
|
||||
epicsThreadSleep(1.0);
|
||||
while (1)
|
||||
epicsThreadSuspendSelf();
|
||||
|
||||
if (shouldAbort) {
|
||||
errlogPrintf("cantProceed() Calling abort()\n");
|
||||
errlogFlush();
|
||||
abort();
|
||||
} else {
|
||||
while (1)
|
||||
epicsThreadSuspendSelf();
|
||||
}
|
||||
}
|
||||
@@ -213,12 +213,12 @@ LIBCOM_API epicsMutexLockStatus epicsStdCall epicsMutexLock(
|
||||
* This routine does not return if the identifier is invalid.
|
||||
* \param ID The mutex identifier.
|
||||
**/
|
||||
#define epicsMutexMustLock(ID) { \
|
||||
epicsMutexLockStatus status = epicsMutexLock(ID); \
|
||||
if(status != epicsMutexLockOK) { \
|
||||
cantProceed("epicsMutexMustLock() failed at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
#define epicsMutexMustLock(ID) { \
|
||||
epicsMutexLockStatus status = epicsMutexLock(ID); \
|
||||
if(status != epicsMutexLockOK) { \
|
||||
cantProceed("epicsMutexMustLock() failed at %s:%d\n", \
|
||||
__FILE__, __LINE__); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**\brief Similar to epicsMutexLock() except that the call returns immediately,
|
||||
|
||||
@@ -15,19 +15,20 @@
|
||||
|
||||
#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE
|
||||
#include <epicsStdio.h>
|
||||
#include <rtems.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <rtems/rtems_bsdnet_internal.h>
|
||||
#include "epicsTime.h"
|
||||
#include "osdTime.h"
|
||||
#include "osiNTPTime.h"
|
||||
#include "osiClockTime.h"
|
||||
#include "generalTimeSup.h"
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtems_bsdnet_internal.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern rtems_interval rtemsTicksPerSecond;
|
||||
|
||||
Reference in new issue
Block a user