dovecot-2.2: Make sure errno is preserved in non-delayed signal ...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jun 1 02:27:11 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/fbeac7272069
changeset: 16436:fbeac7272069
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jun 01 02:25:54 2013 +0300
description:
Make sure errno is preserved in non-delayed signal handlers.
The current code didn't have any signal handlers that modified errno, so
this doesn't fix any bugs.

diffstat:

 src/lib/lib-signals.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r 199769f2979f -r fbeac7272069 src/lib/lib-signals.c
--- a/src/lib/lib-signals.c	Fri May 31 17:36:45 2013 +0300
+++ b/src/lib/lib-signals.c	Sat Jun 01 02:25:54 2013 +0300
@@ -97,6 +97,7 @@
 #endif
 {
 	struct signal_handler *h;
+	int saved_errno;
 	char c = 0;
 
 #if defined(SI_NOINFO) || !defined(SA_SIGINFO)
@@ -123,21 +124,20 @@
 	/* remember that we're inside a signal handler which might have been
 	   called at any time. don't do anything that's unsafe. we might also
 	   get interrupted by another signal while inside this handler. */
+	saved_errno = errno;
 	for (h = signal_handlers[signo]; h != NULL; h = h->next) {
 		if ((h->flags & LIBSIG_FLAG_DELAYED) == 0)
 			h->handler(si, h->context);
 		else if (pending_signals[signo].si_signo == 0) {
 			pending_signals[signo] = *si;
 			if (!have_pending_signals) {
-				int saved_errno = errno;
-
 				if (write(sig_pipe_fd[1], &c, 1) != 1)
 					i_error("write(sigpipe) failed: %m");
 				have_pending_signals = TRUE;
-				errno = saved_errno;
 			}
 		}
 	}
+	errno = saved_errno;
 }
 
 #ifdef SA_SIGINFO


More information about the dovecot-cvs mailing list