diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-08-01 08:18:42 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-08-01 08:18:42 +0000 |
commit | 6c305fdc9a635e03727b19425318ce2eab924c0b (patch) | |
tree | 457aa0ca158b9f3a639b122f38ab66414e83df2e /syslogd.c | |
parent | 43df3e50decc185be43ce0269641de7997101ebc (diff) | |
download | rsyslog-6c305fdc9a635e03727b19425318ce2eab924c0b.tar.gz rsyslog-6c305fdc9a635e03727b19425318ce2eab924c0b.tar.bz2 rsyslog-6c305fdc9a635e03727b19425318ce2eab924c0b.zip |
- 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.
Diffstat (limited to 'syslogd.c')
-rw-r--r-- | syslogd.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -163,6 +163,9 @@ #include <sys/file.h> #include <sys/un.h> #include <sys/time.h> +#ifdef BSD +# include <sys/timespec.h> +#endif #include <sys/resource.h> #include <signal.h> @@ -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); |