mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
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 <horms@verge.net.au>
This commit is contained in:
parent
ac88cfe452
commit
235fcfcf14
@ -1574,6 +1574,16 @@ mailer <mailername> <ip>:<port>
|
||||
server srv1 192.168.0.30:80
|
||||
server srv2 192.168.0.31:80
|
||||
|
||||
timeout mail <time>
|
||||
Defines the time available for a mail/connection to be made and send to
|
||||
the mail-server. If not defined the default value is 10 seconds. To allow
|
||||
for at least two SYN-ACK packets to be send during initial TCP handshake it
|
||||
is advised to keep this value above 4 seconds.
|
||||
|
||||
Example:
|
||||
mailers mymailers
|
||||
timeout mail 20s
|
||||
mailer smtp1 192.168.0.1:587
|
||||
|
||||
4. Proxies
|
||||
----------
|
||||
|
@ -56,6 +56,9 @@ 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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2537,6 +2537,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;
|
||||
@ -2607,7 +2610,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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user