Skip to content

Commit

Permalink
On VxWorks, errno cannot be passed between threads
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-zimoch committed Aug 15, 2023
1 parent 00dc55b commit b6a0abb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions modules/libcom/src/error/errlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ static struct {
int atExit;
int sevToLog;
int toConsole;
int ttyConsole;
FILE *console;

/* A loop counter maintained by errlogThread. */
Expand Down Expand Up @@ -164,7 +163,8 @@ size_t msgbufCommit(size_t nchar, int localEcho)
/* errlogThread is not running, so we print directly
* and then abandon the buffer.
*/
fprintf(pvt.console, "%s", start);
FILE* console = pvt.console ? pvt.console : stderr;
fprintf(console, "%s", start);

} else if(!atExit) {
start[0u] = ERL_STATE_READY | (localEcho ? ERL_LOCALECHO : 0);
Expand Down Expand Up @@ -476,8 +476,7 @@ int errlogSetConsole(FILE *stream)
{
errlogInit(0);
epicsMutexMustLock(pvt.msgQueueLock);
pvt.console = stream ? stream : stderr;
pvt.ttyConsole = isATTY(pvt.console);
pvt.console = stream;
epicsMutexUnlock(pvt.msgQueueLock);
/* make sure worker has stopped writing to the previous stream */
errlogSequence();
Expand Down Expand Up @@ -551,8 +550,7 @@ static void errlogInitPvt(void *arg)
pvt.maxMsgSize = pconfig->maxMsgSize;
ellInit(&pvt.listenerList);
pvt.toConsole = TRUE;
pvt.console = stderr;
pvt.ttyConsole = isATTY(stderr);
pvt.console = NULL;
pvt.waitForWork = epicsEventCreate(epicsEventEmpty);
pvt.listenerLock = epicsMutexCreate();
pvt.msgQueueLock = epicsMutexCreate();
Expand Down Expand Up @@ -641,8 +639,8 @@ static void errlogThread(void)
} else {
/* snapshot and swap buffers for use while unlocked */
size_t nLost = pvt.nLost;
FILE *console = pvt.toConsole ? pvt.console : NULL;
int ttyConsole = pvt.ttyConsole;
FILE *console = pvt.toConsole ? pvt.console ? pvt.console : stderr : NULL;
int ttyConsole = console ? isATTY(console) : 0;
size_t pos = 0u;
buffer_t *print;

Expand Down

0 comments on commit b6a0abb

Please sign in to comment.