fixed a potential race condition with enqueueMsg() - thanks to mildew for

making me aware of this issue
This commit is contained in:
Rainer Gerhards 2007-12-17 06:57:30 +00:00
parent e45bbf5c66
commit c55bb999b2

View File

@ -2209,13 +2209,6 @@ void printline(char *hname, char *msg, int bParseHost)
logmsg(pri, pMsg, SYNC_FILE);
/* rgerhards 2004-11-11:
* we are done with the message object. If it still is
* stored somewhere, we can call discard anyhow. This
* is handled via the reference count - see description
* of msg_t for details.
*/
MsgDestruct(pMsg);
return;
}
@ -2233,8 +2226,6 @@ logmsgInternal(int pri, char *msg, int flags)
{
msg_t *pMsg;
dbgprintf("logmsgInternal: msg passed: '%s'\n", msg);
if((pMsg = MsgConstruct()) == NULL){
/* rgerhards 2004-11-09: calling panic might not be the
* brightest idea - however, it is the best I currently have
@ -2270,7 +2261,6 @@ dbgprintf("logmsgInternal: msg passed: '%s'\n", msg);
* message to the queue engine.
*/
logmsg(pri, pMsg, flags);
MsgDestruct(pMsg);
}
}
@ -2718,7 +2708,7 @@ static void enqueueMsg(msg_t *pMsg)
goto unlock;
}
}
queueAdd(fifo, MsgAddRef(pMsg));
queueAdd(fifo, pMsg);
unlock:
/* now activate the worker thread */
pthread_mutex_unlock(fifo->mut);
@ -5474,7 +5464,6 @@ static void processImInternal(void)
while(iminternalRemoveMsg(&iPri, &pMsg, &iFlags) == RS_RET_OK) {
logmsg(iPri, pMsg, iFlags);
MsgDestruct(pMsg);
}
}