On Wed, Nov 17, 2010 at 09:39:17AM +0100, Lars Ellenberg wrote: > On Fri, Nov 12, 2010 at 05:04:35PM +0100, [email protected] wrote: > ================================ > [PATCH 10 of 10] ha_logd: Add a SIGHUP signal handler to close/open log files > [PATCH 08 of 10] cl_log: Restore old logfile open/seek/write/close behaviour > > Conceptually changed. > Proposed patches attached.
There was one missing, attached now. > Note: not even compile tested :( > Please try/comment. -- : Lars Ellenberg : LINBIT | Your Way to High Availability : DRBD/HA support and consulting http://www.linbit.com DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
# HG changeset patch # User Lars Ellenberg <[email protected]> # Date 1289984632 -3600 # Node ID 5d92ad084d085088013f0b207d583dee9db3b127 # Parent 86554a4bbd50f23c2c7c2183740d85369510ee5d ha_logd: Add a SIGHUP signal handler to timely close/open log files Without the signal handler, it may take some time until cl_log realises the log rotation. diff --git a/logd/ha_logd.c b/logd/ha_logd.c --- a/logd/ha_logd.c +++ b/logd/ha_logd.c @@ -708,6 +708,21 @@ logd_term_action(int sig, gpointer userd return TRUE; } +/* + * Handle SIGHUP to re-open log files + */ +static gboolean +logd_hup_action(int sig, gpointer userdata) +{ + cl_log_close_log_files(); + if (write_process_pid) + /* do we want to propagate the HUP, + * or do we assume that it was a killall anyways? */ + CL_KILL(write_process_pid, SIGHUP); + else + cl_log(LOG_INFO, "SIGHUP received, re-opened log files"); + return TRUE; +} static void read_msg_process(IPC_Channel* chan) @@ -747,6 +762,8 @@ read_msg_process(IPC_Channel* chan) G_main_add_IPC_Channel(G_PRIORITY_DEFAULT, chan, FALSE,NULL,NULL,NULL); + G_main_add_SignalHandler(G_PRIORITY_DEFAULT, SIGHUP, + logd_hup_action, mainloop, NULL); g_main_run(mainloop); return; @@ -862,6 +879,9 @@ write_msg_process(IPC_Channel* readchan) G_main_add_SignalHandler(G_PRIORITY_HIGH, SIGTERM, logd_term_write_action, mainloop, NULL); + + G_main_add_SignalHandler(G_PRIORITY_DEFAULT, SIGHUP, + logd_hup_action, mainloop, NULL); g_main_run(mainloop);
_______________________________________________________ Linux-HA-Dev: [email protected] http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
