MEDIUM: mailers: Init alerts during conf parsing and refactor their processing
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 20 Oct 2017 19:34:32 +0000 (21:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 10:36:12 +0000 (11:36 +0100)
commit0108bb3e401e515d4c304600e822af0de2e45043
treeb1de98a04dc16a13d951f47a4b1bee7d3ed39ec1
parentde1a75b86954ede54cdc82cc913ef6b17e2db6f5
MEDIUM: mailers: Init alerts during conf parsing and refactor their processing

Email alerts relies on checks to send emails. The link between a mailers section
and a proxy was resolved during the configuration parsing, But initialization was
done when the first alert is triggered. This implied memory allocations and
tasks creations. With this patch, everything is now initialized during the
configuration parsing. So when an alert is triggered, only the memory required
by this alert is dynamically allocated.

Moreover, alerts processing had a flaw. The task handler used to process alerts
to be sent to the same mailer, process_email_alert, was designed to give back
the control to the scheduler when an alert was sent. So there was a delay
between the sending of 2 consecutives alerts (the min of
"proxy->timeout.connect" and "mailer->timeout.mail"). To fix this problem, now,
we try to process as much queued alerts as possible when the task is woken up.
include/proto/checks.h
include/types/proxy.h
src/cfgparse.c
src/checks.c