dovecot-1.2: lib-signals: Don't assert-crash with nested signal ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 8 21:50:06 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/8fd1ee439437
changeset: 9371:8fd1ee439437
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 14:50:01 2009 -0400
description:
lib-signals: Don't assert-crash with nested signal handler calls.
diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
src/lib/lib-signals.c | 8 +++++---
diffs (33 lines):
diff -r 5f9782109fcf -r 8fd1ee439437 src/lib/lib-signals.c
--- a/src/lib/lib-signals.c Mon Sep 07 11:46:51 2009 -0400
+++ b/src/lib/lib-signals.c Tue Sep 08 14:50:01 2009 -0400
@@ -95,7 +95,8 @@ static void sig_handler(int signo, sigin
return;
/* remember that we're inside a signal handler which might have been
- called at any time. don't do anything that's unsafe. */
+ called at any time. don't do anything that's unsafe. we might also
+ get interrupted by another signal while inside this handler. */
for (h = signal_handlers[signo]; h != NULL; h = h->next) {
if (!h->delayed)
h->handler(si, h->context);
@@ -125,7 +126,7 @@ static void signal_read(void *context AT
siginfo_t signals[MAX_SIGNAL_VALUE+1];
sigset_t fullset, oldset;
struct signal_handler *h;
- char buf[2];
+ char buf[64];
int signo;
ssize_t ret;
@@ -134,8 +135,9 @@ static void signal_read(void *context AT
if (sigprocmask(SIG_BLOCK, &fullset, &oldset) < 0)
i_fatal("sigprocmask() failed: %m");
+ /* typically we should read only a single byte, but if a signal
+ is sent while signal handler is running we might get more. */
ret = read(sig_pipe_fd[0], buf, sizeof(buf));
- i_assert(ret <= 1);
if (ret > 0) {
memcpy(signals, pending_signals, sizeof(signals));
memset(pending_signals, 0, sizeof(pending_signals));
More information about the dovecot-cvs
mailing list