Description: Allow a SIGALRM to force a delivery attempt.
Origin: other: http://svn.ringlet.net/svn/ringlet/mail/dma/
Forwarded: yes
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2010-06-19

--- a/dma.c
+++ b/dma.c
@@ -267,6 +267,12 @@
 }
 
 static void
+sig_alarm(int signo)
+{
+	(void)signo;	/* so that gcc doesn't complain */
+}
+
+static void
 deliver(struct qitem *it)
 {
 	int error;
@@ -301,7 +307,12 @@
 				 MAX_TIMEOUT);
 			goto bounce;
 		}
+		if (signal(SIGALRM, sig_alarm) == SIG_ERR)
+			syslog(LOG_WARNING,
+				"Could not set an alarm handler, the backoff "
+				"delay cannot be interrupted");
 		sleep(backoff);
+		signal(SIGALRM, SIG_DFL);
 		backoff *= 2;
 		if (backoff > MAX_RETRY)
 			backoff = MAX_RETRY;
