#include <haproxy/tcpcheck-t.h>
#include <haproxy/thread-t.h>
+/* flags for proxy.email_alert.flags */
+enum proxy_email_alert_flags {
+ PR_EMAIL_ALERT_NONE = 0,
+ PR_EMAIL_ALERT_SET, /* set if email alert settings are present */
+ PR_EMAIL_ALERT_RESOLVED, /* set if email alert settings were resolved */
+};
+
struct mailer {
char *id;
struct mailers *mailers;
char *myhostname; /* Identity to use in HELO command sent to mailer */
int level; /* Maximum syslog level of messages to send
* email alerts for */
- int set; /* True if email_alert settings are present */
+ int flags; /* check mailers.h for available flags */
struct email_alertq *queues; /* per-mailer alerts queues */
} email_alert;
#include <haproxy/http_htx.h>
#include <haproxy/http_ext.h>
#include <haproxy/http_rules.h>
+#include <haproxy/mailers-t.h>
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/peers.h>
goto out;
}
/* Indicate that the email_alert is at least partially configured */
- curproxy->email_alert.set = 1;
+ curproxy->email_alert.flags |= PR_EMAIL_ALERT_SET;
}/* end else if (!strcmp(args[0], "email-alert")) */
else if (strcmp(args[0], "persist") == 0) { /* persist */
if (*(args[1]) == 0) {
}
}
- if (curproxy->email_alert.set) {
+ if (curproxy->email_alert.flags & PR_EMAIL_ALERT_SET) {
if (!(curproxy->email_alert.mailers.name && curproxy->email_alert.from && curproxy->email_alert.to)) {
ha_warning("'email-alert' will be ignored for %s '%s' (the presence any of "
"'email-alert from', 'email-alert level' 'email-alert mailers', "
mls->users++;
free(p->email_alert.mailers.name);
p->email_alert.mailers.m = mls;
+ p->email_alert.flags |= PR_EMAIL_ALERT_RESOLVED;
p->email_alert.queues = queues;
return 0;
void free_email_alert(struct proxy *p)
{
- ha_free(&p->email_alert.mailers.name);
+ if (!(p->email_alert.flags & PR_EMAIL_ALERT_RESOLVED))
+ ha_free(&p->email_alert.mailers.name);
ha_free(&p->email_alert.from);
ha_free(&p->email_alert.to);
ha_free(&p->email_alert.myhostname);
LIST_DEL_INIT(&lf->list);
chunk_destroy(&px->log_tag);
+
+ free_email_alert(px);
}
void free_proxy(struct proxy *p)
proxy_release_conf_errors(defproxy);
deinit_proxy_tcpcheck(defproxy);
- free_email_alert(defproxy);
/* FIXME: we cannot free uri_auth because it might already be used by
* another proxy (legacy code for stats URI ...). Refcount anyone ?
if (defproxy->check_command)
curproxy->check_command = strdup(defproxy->check_command);
+ BUG_ON(curproxy->email_alert.flags & PR_EMAIL_ALERT_RESOLVED);
if (defproxy->email_alert.mailers.name)
curproxy->email_alert.mailers.name = strdup(defproxy->email_alert.mailers.name);
if (defproxy->email_alert.from)
if (defproxy->email_alert.myhostname)
curproxy->email_alert.myhostname = strdup(defproxy->email_alert.myhostname);
curproxy->email_alert.level = defproxy->email_alert.level;
- curproxy->email_alert.set = defproxy->email_alert.set;
+ curproxy->email_alert.flags = defproxy->email_alert.flags;
return 0;
}