This will allow new logging configuration to take effect once changes to reinitialise haproxy are introduced. --- include/proto/log.h | 5 +++++ src/haproxy.c | 1 + src/log.c | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/include/proto/log.h b/include/proto/log.h index 45bec88..ecd51b1 100644 --- a/include/proto/log.h +++ b/include/proto/log.h @@ -66,6 +66,11 @@ void qfprintf(FILE *out, const char *fmt, ...) __attribute__ ((format(printf, 2, 3))); /* + * Close and clean up logs + */ +void close_log(void); + +/* * This function sends a syslog message to both log servers of a proxy, * or to global log servers if the proxy is NULL. * It also tries not to waste too much time computing the message header. diff --git a/src/haproxy.c b/src/haproxy.c index 1f02902..a0bc8f5 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1055,6 +1055,7 @@ void run(int argc, char **argv) socket_cache_make_all_available(); init(argc, argv); + close_log(); /* It will automatically be reopened as needed */ signal_register_fct(SIGQUIT, dump, SIGQUIT); signal_register_fct(SIGUSR1, sig_soft_stop, SIGUSR1); signal_register_fct(SIGHUP, sig_dump_state, SIGHUP); diff --git a/src/log.c b/src/log.c index 4cd3b55..5da1260 100644 --- a/src/log.c +++ b/src/log.c @@ -217,6 +217,20 @@ static inline int logsrv_addrlen(const struct logsrv *logsrv) return -1; } +static int logfdunix = -1; /* syslog to AF_UNIX socket */ +static int logfdinet = -1; /* syslog to AF_INET socket */ +static long tvsec = -1; /* to force the string to be initialized */ + +void close_log(void) +{ + if (logfdunix >= 0) + close(logfdunix); + logfdunix = -1; + if (logfdinet >= 0) + close(logfdinet); + logfdinet = -1; +} + /* * This function sends a syslog message to both log servers of a proxy, * or to global log servers if the proxy is NULL. @@ -226,9 +240,6 @@ static inline int logsrv_addrlen(const struct logsrv *logsrv) static void vsend_log(struct proxy *p, int level, const char *message, va_list argp) { - static int logfdunix = -1; /* syslog to AF_UNIX socket */ - static int logfdinet = -1; /* syslog to AF_INET socket */ - static long tvsec = -1; /* to force the string to be initialized */ static char logmsg[MAX_SYSLOG_LEN]; static char *dataptr = NULL; int fac_level; -- 1.7.2.3