Commit 4eec2c4a authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(kom_signal_adapter): New static variable.

(server_init): Use oop_signal_new, since I don't trust the way
	liboop uses siglongjmp to break out of a signal handler.
	Ignore the signals before registering them with liboop, to get
	a proper behaviour on shutdown.
(main): Adjusted to use the signal adapter.
parent 0f131c35
/*
* $Id: ramkomd.c,v 0.114 2003/07/12 22:26:34 ceder Exp $
* $Id: ramkomd.c,v 0.115 2003/07/13 11:07:16 ceder Exp $
* Copyright (C) 1991-1999, 2001-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -128,6 +128,8 @@ int buglevel = 0;
intended for debugging and the test suite. */
static int foreground = 0;
static oop_adapter_signal *kom_signal_adapter;
static void dump_exit_statistics(void);
static void free_kom_info(void);
static oop_call_signal sighandler_hup;
......@@ -171,8 +173,35 @@ server_init(const char *host, const char * client_port)
kom_server_oop_src = oop_sys_new();
if (kom_server_oop_src == NULL)
restart_kom("server_init: can't get system event source\n");
src = oop_sys_source(kom_server_oop_src);
oop_sys_use_sa_restart();
kom_signal_adapter = oop_signal_new(oop_sys_source(kom_server_oop_src));
if (kom_signal_adapter == NULL)
restart_kom("server_init: can't create signal adapter\n");
/* Ignore the signals before we register them with liboop. That
way, when liboop reinstalls the old signal handler during
shutdown, we will ignore them rather than stop prematurely
during the shutdown. This is especially important for the
SIGHUP signal, which is sent periodically by updateLysKOM. */
#ifdef HAVE_STRUCT_SIGACTION
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
set_handler_sig_ign(&act);
sigaction(SIGHUP, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
sigaction(SIGUSR1, &act, NULL);
sigaction(SIGUSR2, &act, NULL);
sigaction(SIGWINCH, &act, NULL);
#else
signal(SIGHUP, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
signal(SIGWINCH, SIG_IGN);
#endif
src = oop_signal_source(kom_signal_adapter);
oop_signal_use_sa_restart();
src->on_signal(src, SIGHUP, sighandler_hup, NULL);
src->on_signal(src, SIGQUIT, sighandler_quit, NULL);
src->on_signal(src, SIGUSR1, sighandler_usr1, NULL);
......@@ -597,12 +626,13 @@ main (int argc,
isc_shutdown(kom_server_mcb);
cache_sync_all();
unlock_db();
src = oop_sys_source(kom_server_oop_src);
src = oop_signal_source(kom_signal_adapter);
src->cancel_signal(src, SIGWINCH, sighandler_winch, NULL);
src->cancel_signal(src, SIGUSR2, sighandler_usr2, NULL);
src->cancel_signal(src, SIGUSR1, sighandler_usr1, NULL);
src->cancel_signal(src, SIGQUIT, sighandler_quit, NULL);
src->cancel_signal(src, SIGHUP, sighandler_hup, NULL);
oop_signal_delete(kom_signal_adapter);
oop_sys_delete(kom_server_oop_src);
/* Finish */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment