From 4aee02256cb1542139cdf399bd22bd7496d9611d Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 21 Jun 2005 14:14:55 +0000 Subject: [PATCH] Implement daemon_startup_{retries,sleep} to control startup retrying. --- doc/doc-misc/WishList | 8 +------- doc/doc-txt/ChangeLog | 4 +++- doc/doc-txt/NewStuff | 8 +++++++- doc/doc-txt/OptionLists.txt | 4 +++- src/src/daemon.c | 12 +++++++----- src/src/globals.c | 4 +++- src/src/globals.h | 4 +++- src/src/readconf.c | 4 +++- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/doc/doc-misc/WishList b/doc/doc-misc/WishList index adc8b0bba..7624940c4 100644 --- a/doc/doc-misc/WishList +++ b/doc/doc-misc/WishList @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-misc/WishList,v 1.39 2005/06/16 15:48:58 ph10 Exp $ +$Cambridge: exim/doc/doc-misc/WishList,v 1.40 2005/06/21 14:14:55 ph10 Exp $ EXIM 4 WISH LIST ---------------- @@ -1881,12 +1881,6 @@ file would contain the complete email. I suppose there may be other scanning solutions with a similar requirement." ------------------------------------------------------------------------------ -(320) 03-Mar-05 T Options to control daemon retry binding - -Currently the daemon tries 10 times at 30-second intervals to listen on an IP -address. The wish is for options to control these numbers. ------------------------------------------------------------------------------- - (321) 07-Mar-05 S Run an ACL on a sync error ... and possibly "accept" or "deny" it. diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index aea7fe9e8..158929d03 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.165 2005/06/20 13:58:22 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.166 2005/06/21 14:14:55 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -172,6 +172,8 @@ PH/22 Fixed some oversights/typos causing bugs when Exim is compiled with These problems did NOT occur unless DomainKeys support was compiled. +PH/23 Added daemon_startup_retries and daemon_startup_sleep. + Exim version 4.51 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 65b0fc678..0805e0b5b 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.50 2005/06/16 20:03:43 tom Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.51 2005/06/21 14:14:55 ph10 Exp $ New Features in Exim -------------------- @@ -342,6 +342,12 @@ TK/02 There are two new expansion items to help with the implementation of sender='${quote_mysql:$sender_address}'} \ {$value}fail}}} +PH/04 There are two new options that control the retrying done by the daemon + at startup when it cannot immediately bind a socket (typically because + the socket is already in use). The default values reproduce what were + built-in constants previously: daemon_startup_retries defines the number + of retries after the first failure (default 9); daemon_startup_sleep + defines the length of time to wait between retries (default 30s). Version 4.51 diff --git a/doc/doc-txt/OptionLists.txt b/doc/doc-txt/OptionLists.txt index ac1e06a11..53b76d304 100644 --- a/doc/doc-txt/OptionLists.txt +++ b/doc/doc-txt/OptionLists.txt @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.8 2005/05/03 14:20:00 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.9 2005/06/21 14:14:55 ph10 Exp $ LISTS OF EXIM OPTIONS --------------------- @@ -140,6 +140,8 @@ create_file string "anywhere" appendfile current_directory string unset transports 4.00 unset queryprogram 4.00 daemon_smtp_ports string unset main 1.75 pluralised in 4.21 +daemon_startup_retries int 9 main 4.52 +daemon_startup_sleep time 30s main 4.52 data string unset redirect 4.00 data_timeout time 5m smtp debug_print string* unset authenticators 4.00 diff --git a/src/src/daemon.c b/src/src/daemon.c index 21d111023..974785c24 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/daemon.c,v 1.10 2005/03/15 14:09:12 ph10 Exp $ */ +/* $Cambridge: exim/src/src/daemon.c,v 1.11 2005/06/21 14:14:55 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1249,7 +1249,6 @@ if (daemon_listen) { BOOL wildcard; ip_address_item *ipa2; - int retries = 9; int af; if (Ustrchr(ipa->address, ':') != NULL) @@ -1327,13 +1326,16 @@ if (daemon_listen) msg = US strerror(errno); addr = wildcard? ((af == AF_INET6)? US"(any IPv6)" : US"(any IPv4)") : ipa->address; - if (retries-- <= 0) + if (daemon_startup_retries <= 0) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "socket bind() to port %d for address %s failed: %s: " "daemon abandoned", ipa->port, addr, msg); log_write(0, LOG_MAIN, "socket bind() to port %d for address %s " - "failed: %s: waiting before trying again", ipa->port, addr, msg); - sleep(30); + "failed: %s: waiting %s before trying again (%d more %s)", + ipa->port, addr, msg, readconf_printtime(daemon_startup_sleep), + daemon_startup_retries, (daemon_startup_retries > 1)? "tries" : "try"); + daemon_startup_retries--; + sleep(daemon_startup_sleep); } DEBUG(D_any) diff --git a/src/src/globals.c b/src/src/globals.c index ee0fb6e65..1f57ff383 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.c,v 1.29 2005/06/16 20:01:29 tom Exp $ */ +/* $Cambridge: exim/src/src/globals.c,v 1.30 2005/06/21 14:14:55 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -392,6 +392,8 @@ uschar *csa_status = NULL; BOOL daemon_listen = FALSE; uschar *daemon_smtp_port = US"smtp"; +int daemon_startup_retries = 9; +int daemon_startup_sleep = 30; BOOL debug_daemon = FALSE; int debug_fd = -1; FILE *debug_file = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index aed97d3e9..0c64224a2 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/globals.h,v 1.21 2005/06/16 20:01:29 tom Exp $ */ +/* $Cambridge: exim/src/src/globals.h,v 1.22 2005/06/21 14:14:55 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -218,6 +218,8 @@ extern uschar *csa_status; /* Client SMTP Authorization result */ extern BOOL daemon_listen; /* True if listening required */ extern uschar *daemon_smtp_port; /* Can be a list of ports */ +extern int daemon_startup_retries; /* Number of times to retry */ +extern int daemon_startup_sleep; /* Sleep between retries */ extern BOOL debug_daemon; /* Debug the daemon process only */ extern int debug_fd; /* The fd for debug_file */ extern FILE *debug_file; /* Where to write debugging info */ diff --git a/src/src/readconf.c b/src/src/readconf.c index 6a6b3ba2a..b5c113014 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/readconf.c,v 1.9 2005/05/24 08:15:02 tom Exp $ */ +/* $Cambridge: exim/src/src/readconf.c,v 1.10 2005/06/21 14:14:55 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -186,6 +186,8 @@ static optionlist optionlist_config[] = { { "check_spool_space", opt_Kint, &check_spool_space }, { "daemon_smtp_port", opt_stringptr|opt_hidden, &daemon_smtp_port }, { "daemon_smtp_ports", opt_stringptr, &daemon_smtp_port }, + { "daemon_startup_retries", opt_int, &daemon_startup_retries }, + { "daemon_startup_sleep", opt_time, &daemon_startup_sleep }, { "delay_warning", opt_timelist, &delay_warning }, { "delay_warning_condition", opt_stringptr, &delay_warning_condition }, { "deliver_drop_privilege", opt_bool, &deliver_drop_privilege }, -- 2.30.2