]> git.ipfire.org Git - people/ms/dma.git/blob - patches/35-delivery-retry.patch
Really fix the build on the GNU Hurd.
[people/ms/dma.git] / patches / 35-delivery-retry.patch
1 Description: Randomize the retry timeouts a bit.
2 Origin: other: http://svn.ringlet.net/svn/ringlet/mail/dma/
3 Forwarded: http://bugs.launchpad.net/dma/+bug/599542
4 Author: Peter Pentchev <roam@ringlet.net>
5 Last-Update: 2010-06-28
6
7 --- a/dma.c
8 +++ b/dma.c
9 @@ -276,7 +276,7 @@
10 deliver(struct qitem *it)
11 {
12 int error;
13 - unsigned int backoff = MIN_RETRY;
14 + unsigned int backoff = it->remote? MIN_RETRY: MIN_RETRY_LOCAL;
15 const char *errmsg = "unknown bounce reason";
16 struct timeval now;
17 struct stat st;
18 @@ -313,7 +313,13 @@
19 "delay cannot be interrupted");
20 sleep(backoff);
21 signal(SIGALRM, SIG_DFL);
22 - backoff *= 2;
23 + backoff = backoff * 2 + (
24 +#ifdef HAVE_RANDOM
25 + random()
26 +#else
27 + rand()
28 +#endif
29 + % RETRY_JITTER);
30 if (backoff > MAX_RETRY)
31 backoff = MAX_RETRY;
32 goto retry;
33 --- a/dma.h
34 +++ b/dma.h
35 @@ -48,7 +48,9 @@
36
37 #define BUF_SIZE 2048
38 #define MIN_RETRY 300 /* 5 minutes */
39 +#define MIN_RETRY_LOCAL 30 /* 30 seconds */
40 #define MAX_RETRY (3*60*60) /* retry at least every 3 hours */
41 +#define RETRY_JITTER 10
42 #define MAX_TIMEOUT (5*24*60*60) /* give up after 5 days */
43 #ifndef PATH_MAX
44 #define PATH_MAX 1024 /* Max path len */