aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-01 18:51:17 +0100
committerMax Kellermann <max@duempel.org>2009-01-01 18:51:17 +0100
commit2f71b647f48592ced0811ec66907068a3e236d6a (patch)
tree002b64888a21e6e855585128e64aa39c4fcfae9e
parente93136ef0fac69b4bb7f02ba7e3b348827d597ea (diff)
downloadmpd-2f71b647f48592ced0811ec66907068a3e236d6a.tar.gz
mpd-2f71b647f48592ced0811ec66907068a3e236d6a.tar.xz
mpd-2f71b647f48592ced0811ec66907068a3e236d6a.zip
sig_handlers: use event_pipe for delivering SIGHUP
The signal_check library went out of order when we started using the GLib main loop. Convert the SIGHUP handler to use event_pipe instead.
-rw-r--r--src/event_pipe.h3
-rw-r--r--src/sig_handlers.c25
-rw-r--r--src/sig_handlers.h2
3 files changed, 17 insertions, 13 deletions
diff --git a/src/event_pipe.h b/src/event_pipe.h
index 8da10c759..3888939c8 100644
--- a/src/event_pipe.h
+++ b/src/event_pipe.h
@@ -40,6 +40,9 @@ enum pipe_event {
/** must call syncPlayerAndPlaylist() */
PIPE_EVENT_PLAYLIST,
+ /** SIGHUP received: reload configuration, roll log file */
+ PIPE_EVENT_RELOAD,
+
PIPE_EVENT_MAX
};
diff --git a/src/sig_handlers.c b/src/sig_handlers.c
index 5fefb82a0..660107200 100644
--- a/src/sig_handlers.c
+++ b/src/sig_handlers.c
@@ -18,10 +18,10 @@
*/
#include "sig_handlers.h"
-#include "command.h"
#include "signal_check.h"
#include "log.h"
#include "main.h"
+#include "event_pipe.h"
#include <glib.h>
@@ -34,6 +34,11 @@ static void exit_signal_handler(G_GNUC_UNUSED int signum)
g_main_loop_quit(main_loop);
}
+static void reload_signal_handler(G_GNUC_UNUSED int signum)
+{
+ event_pipe_emit_fast(PIPE_EVENT_RELOAD);
+}
+
static void
x_sigaction(int signum, const struct sigaction *act)
{
@@ -41,16 +46,11 @@ x_sigaction(int signum, const struct sigaction *act)
g_error("sigaction() failed: %s", strerror(errno));
}
-int handlePendingSignals(void)
+static void
+handle_reload_event(void)
{
- if (signal_is_pending(SIGHUP)) {
- DEBUG("got SIGHUP, rereading DB\n");
- signal_clear(SIGHUP);
- if (cycle_log_files() < 0)
- return COMMAND_RETURN_KILL;
- }
-
- return 0;
+ DEBUG("got SIGHUP, rereading DB\n");
+ cycle_log_files();
}
void initSigHandlers(void)
@@ -66,6 +66,9 @@ void initSigHandlers(void)
x_sigaction(SIGINT, &sa);
x_sigaction(SIGTERM, &sa);
+ event_pipe_register(PIPE_EVENT_RELOAD, handle_reload_event);
+ sa.sa_handler = reload_signal_handler;
+ x_sigaction(SIGHUP, &sa);
+
signal_handle(SIGUSR1);
- signal_handle(SIGHUP);
}
diff --git a/src/sig_handlers.h b/src/sig_handlers.h
index a7a2c6f02..0dc1c569b 100644
--- a/src/sig_handlers.h
+++ b/src/sig_handlers.h
@@ -19,8 +19,6 @@
#ifndef MPD_SIG_HANDLERS_H
#define MPD_SIG_HANDLERS_H
-int handlePendingSignals(void);
-
void initSigHandlers(void);
#endif