Hi Pieter, for this one, could you please add an entry in the doc (configuration.txt) ?
I've re-adjusted the commit message already, you can update this patch. Thanks, Willy
>From f97319506e74e912cb77fa35a3e9d1618b8130f2 Mon Sep 17 00:00:00 2001 From: Pieter Baauw <piba.nl....@gmail.com> Date: Sat, 13 Feb 2016 15:33:40 +0100 Subject: [PATCH 2/4] MINOR: mailers: make it possible to configure the connection timeout This patch introduces a configurable connection timeout for mailers with a new "timeout mail <time>" directive. Acked-by: Simon Horman <ho...@verge.net.au> --- include/types/mailers.h | 4 ++++ src/cfgparse.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/checks.c | 4 +--- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/include/types/mailers.h b/include/types/mailers.h index 07374a7..5f42cb5 100644 --- a/include/types/mailers.h +++ b/include/types/mailers.h @@ -56,6 +56,10 @@ struct mailers { struct mailers *next; /* next mailers section */ int count; /* total number of mailers in this mailers section */ int users; /* number of users of this mailers section */ + struct { /* time to: */ + int mail; /* try connecting to mailserver and sending a email */ + } timeout; + }; diff --git a/src/cfgparse.c b/src/cfgparse.c index 68cee26..9dcae48 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2451,6 +2451,9 @@ int cfg_parse_mailers(const char *file, int linenum, char **args, int kwm) curmailers->conf.file = strdup(file); curmailers->conf.line = linenum; curmailers->id = strdup(args[1]); + curmailers->timeout.mail = DEF_MAILALERTTIME;/* XXX: Would like to Skip to the next alert, if any, ASAP. + * But need enough time so that timeouts don't occur + * during tcp procssing. For now just us an arbitrary default. */ } else if (strcmp(args[0], "mailer") == 0) { /* mailer definition */ struct sockaddr_storage *sk; @@ -2521,7 +2524,43 @@ int cfg_parse_mailers(const char *file, int linenum, char **args, int kwm) newmailer->proto = proto; newmailer->xprt = &raw_sock; newmailer->sock_init_arg = NULL; - } /* neither "mailer" nor "mailers" */ + } + else if (strcmp(args[0], "timeout") == 0) { + if (!*args[1]) { + Alert("parsing [%s:%d] : '%s' expects 'mail' and <time> as arguments.\n", + file, linenum, args[0]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + else if (strcmp(args[1], "mail") == 0) { + const char *res; + unsigned int timeout_mail; + if (!*args[2]) { + Alert("parsing [%s:%d] : '%s %s' expects <time> as argument.\n", + file, linenum, args[0], args[1]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + res = parse_time_err(args[2], &timeout_mail, TIME_UNIT_MS); + if (res) { + Alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n", + file, linenum, *res, args[0]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + if (timeout_mail <= 0) { + Alert("parsing [%s:%d] : '%s %s' expects a positive <time> argument.\n", file, linenum, args[0], args[1]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + curmailers->timeout.mail = timeout_mail; + } else { + Alert("parsing [%s:%d] : '%s' expects 'mail' and <time> as arguments got '%s'.\n", + file, linenum, args[0], args[1]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + } else if (*args[0] != 0) { Alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection); err_code |= ERR_ALERT | ERR_FATAL; diff --git a/src/checks.c b/src/checks.c index 9d6d33e..de0b672 100644 --- a/src/checks.c +++ b/src/checks.c @@ -3108,9 +3108,7 @@ static int init_email_alert_checks(struct server *s) LIST_INIT(&q->email_alerts); - check->inter = DEF_MAILALERTTIME; /* XXX: Would like to Skip to the next alert, if any, ASAP. - * But need enough time so that timeouts don't occur - * during tcp check procssing. For now just us an arbitrary default. */ + check->inter = p->email_alert.mailers.m->timeout.mail; check->rise = DEF_AGENT_RISETIME; check->fall = DEF_AGENT_FALLTIME; err_str = init_check(check, PR_O2_TCPCHK_CHK); -- 2.7.0.windows.1