summaryrefslogtreecommitdiff
path: root/source3/smbd/process.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-01-21 23:24:18 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-27 15:28:07 +0100
commitac61f650ae640c13beee9d48304d7939f700aa11 (patch)
treeb512f8c4cdd63260bbbb1ee2d50807b98d99cab1 /source3/smbd/process.c
parent27f812f3a85ce21ca79143f59c823913f57fa507 (diff)
downloadsamba-ac61f650ae640c13beee9d48304d7939f700aa11.tar.gz
samba-ac61f650ae640c13beee9d48304d7939f700aa11.tar.bz2
samba-ac61f650ae640c13beee9d48304d7939f700aa11.zip
s3:smbd: use signal events for SIGTERM, SIGHUP and SIGCHLD
metze
Diffstat (limited to 'source3/smbd/process.c')
-rw-r--r--source3/smbd/process.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index a07b71e5ac..2326bdab90 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -692,6 +692,56 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
return result;
}
+static void smbd_sig_term_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ exit_server_cleanly("termination signal");
+}
+
+void smbd_setup_sig_term_handler(void)
+{
+ struct tevent_signal *se;
+
+ se = tevent_add_signal(smbd_event_context(),
+ smbd_event_context(),
+ SIGTERM, 0,
+ smbd_sig_term_handler,
+ NULL);
+ if (!se) {
+ exit_server("failed to setup SIGTERM handler");
+ }
+}
+
+static void smbd_sig_hup_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ change_to_root_user();
+ DEBUG(1,("Reloading services after SIGHUP\n"));
+ reload_services(False);
+}
+
+void smbd_setup_sig_hup_handler(void)
+{
+ struct tevent_signal *se;
+
+ se = tevent_add_signal(smbd_event_context(),
+ smbd_event_context(),
+ SIGHUP, 0,
+ smbd_sig_hup_handler,
+ NULL);
+ if (!se) {
+ exit_server("failed to setup SIGHUP handler");
+ }
+}
+
/****************************************************************************
Do all async processing in here. This includes kernel oplock messages, change
notify events etc.
@@ -709,18 +759,6 @@ static void async_processing(void)
select and may have eaten our signal. */
/* Is this till true? -- vl */
process_aio_queue();
-
- if (got_sig_term) {
- exit_server_cleanly("termination signal");
- }
-
- /* check for sighup processing */
- if (reload_after_sighup) {
- change_to_root_user();
- DEBUG(1,("Reloading services after SIGHUP\n"));
- reload_services(False);
- reload_after_sighup = 0;
- }
}
/****************************************************************************
@@ -1830,9 +1868,8 @@ void check_reload(time_t t)
mypid = getpid();
}
- if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) {
+ if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) {
reload_services(True);
- reload_after_sighup = False;
last_smb_conf_reload_time = t;
}