From 6c305fdc9a635e03727b19425318ce2eab924c0b Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 1 Aug 2007 08:18:42 +0000 Subject: - applied a patch from mildew to prevent rsyslogd from freezing under heavy load. This could happen when the queue was full. Now, we drop messages but rsyslogd remains active. --- ChangeLog | 3 +++ configure.ac | 1 + syslogd.c | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3379f0e6..2c666580 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,9 @@ Version 1.17.6 (rgerhards), 2007-07-3? - fixed an invalid value for the MARK timer - unfortunately, there was a testing aid left in place. This resulted in quite frequent MARK messages - added $include config directive +- applied a patch from mildew to prevent rsyslogd from freezing under heavy + load. This could happen when the queue was full. Now, we drop messages + but rsyslogd remains active. --------------------------------------------------------------------------- Version 1.17.5 (rgerhards), 2007-07-30 - continued to work on output module modularization diff --git a/configure.ac b/configure.ac index 24e01f06..1e11c930 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ case "${host}" in esac # Checks for libraries. +AC_CHECK_LIB(rt,clock_gettime,,,) # Checks for header files. AC_HEADER_RESOLV diff --git a/syslogd.c b/syslogd.c index 25e49448..7f0a4673 100644 --- a/syslogd.c +++ b/syslogd.c @@ -163,6 +163,9 @@ #include #include #include +#ifdef BSD +# include +#endif #include #include @@ -2510,6 +2513,7 @@ static void *singleWorker() } else { /* the mutex must be unlocked in any case (important for termination) */ pthread_mutex_unlock(fifo->mut); } + if(debugging_on && bGlblDone && !fifo->empty) dprintf("Worker does not yet terminate because it still has messages to process.\n"); } @@ -2536,6 +2540,7 @@ static void enqueueMsg(msg_t *pMsg) { int iRet; msgQueue *fifo = pMsgQueue; + struct timespec t; assert(pMsg != NULL); @@ -2547,12 +2552,22 @@ static void enqueueMsg(msg_t *pMsg) processMsg(pMsg); } else { /* "normal" mode, threading initialized */ - iRet = pthread_mutex_lock(fifo->mut); + pthread_mutex_lock(fifo->mut); + while (fifo->full) { dprintf ("enqueueMsg: queue FULL.\n"); - pthread_cond_wait (fifo->notFull, fifo->mut); + + clock_gettime (CLOCK_REALTIME, &t); + t.tv_sec += 2; + + if(pthread_cond_timedwait (fifo->notFull, + fifo->mut, &t) != 0) { + dprintf("enqueueMsg: cond timeout, dropping message!\n"); + goto unlock; + } } queueAdd(fifo, MsgAddRef(pMsg)); + unlock: /* now activate the worker thread */ pthread_mutex_unlock(fifo->mut); iRet = pthread_cond_signal(fifo->notEmpty); -- cgit v1.2.3