summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2013-02-14 14:42:21 +0100
committerKarolin Seeger <kseeger@samba.org>2013-04-07 21:27:19 +0200
commit23ac828ba93e2ffc60ced19656af9609dcc1b2ab (patch)
tree29e2e68c15ef4a8be7a913a36ae4b3b7dc9ef009 /source3
parentd7286bb6520ebe03355e98e3311e1d79e2746791 (diff)
downloadsamba-23ac828ba93e2ffc60ced19656af9609dcc1b2ab.tar.gz
printing: move pcap change notifier to bg process
The background print queue process is responsible for printcap cache updates, and should be the only process to send notifications.
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/printing.c57
-rw-r--r--source3/smbd/process.c3
-rw-r--r--source3/smbd/proto.h4
-rw-r--r--source3/smbd/server_reload.c18
4 files changed, 55 insertions, 27 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 376fc7c2b08..21f318c764b 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1656,6 +1656,24 @@ static void add_child_pid(pid_t pid)
num_children += 1;
}
+/****************************************************************************
+ Notify smbds of new printcap data
+**************************************************************************/
+static void reload_pcap_change_notify(struct tevent_context *ev,
+ struct messaging_context *msg_ctx)
+{
+ /*
+ * Reload the printers first in the background process so that
+ * newly added printers get default values created in the registry.
+ *
+ * This will block the process for some time (~1 sec per printer), but
+ * it doesn't block smbd's servering clients.
+ */
+ reload_printers(ev, msg_ctx);
+
+ message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
+}
+
static bool printer_housekeeping_fn(const struct timeval *now,
void *private_data)
{
@@ -1678,6 +1696,30 @@ static bool printer_housekeeping_fn(const struct timeval *now,
return true;
}
+static void printing_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");
+}
+
+static void printing_sig_hup_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ struct messaging_context *msg_ctx = talloc_get_type_abort(
+ private_data, struct messaging_context);
+
+ DEBUG(1,("Reloading printers after SIGHUP\n"));
+ reload_pcap_change_notify(ev, msg_ctx);
+}
+
static pid_t background_lpq_updater_pid = -1;
/****************************************************************************
@@ -1713,6 +1755,7 @@ void start_background_queue(struct tevent_context *ev,
struct tevent_fd *fde;
int ret;
NTSTATUS status;
+ struct tevent_signal *se;
/* Child. */
DEBUG(5,("start_background_queue: background LPQ thread started\n"));
@@ -1727,8 +1770,18 @@ void start_background_queue(struct tevent_context *ev,
smb_panic("reinit_after_fork() failed");
}
- smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler(ev, msg_ctx);
+ se = tevent_add_signal(ev, ev, SIGTERM, 0,
+ printing_sig_term_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("failed to setup SIGTERM handler");
+ }
+ se = tevent_add_signal(ev, ev, SIGHUP, 0,
+ printing_sig_hup_handler,
+ msg_ctx);
+ if (se == NULL) {
+ smb_panic("failed to setup SIGHUP handler");
+ }
if (!serverid_register(procid_self(),
FLAG_MSG_GENERAL|FLAG_MSG_SMBD
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 358d0515ae7..b93b9599fb5 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -957,9 +957,6 @@ static void smbd_sig_hup_handler(struct tevent_context *ev,
change_to_root_user();
DEBUG(1,("Reloading services after SIGHUP\n"));
reload_services(msg_ctx, smbd_server_conn->sock, False);
- if (am_parent) {
- pcap_cache_reload(ev, msg_ctx, &reload_pcap_change_notify);
- }
}
void smbd_setup_sig_hup_handler(struct tevent_context *ev,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index d6f751175c7..2baa58da981 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -770,8 +770,6 @@ NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
/* The following definitions come from smbd/process.c */
void smbd_setup_sig_term_handler(void);
-void smbd_setup_sig_hup_handler(struct tevent_context *ev,
- struct messaging_context *msg_ctx);
bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
bool no_signing, uint32_t seqnum,
bool do_encrypt,
@@ -982,8 +980,6 @@ void reload_printers(struct tevent_context *ev,
struct messaging_context *msg_ctx);
bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
bool test);
-void reload_pcap_change_notify(struct tevent_context *ev,
- struct messaging_context *msg_ctx);
void exit_server(const char *const explanation);
void exit_server_cleanly(const char *const explanation);
void exit_server_fault(void);
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index bda5d08a637..f4c15f8272c 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -160,21 +160,3 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
return(ret);
}
-
-/****************************************************************************
- Notify smbds of new printcap data
-**************************************************************************/
-void reload_pcap_change_notify(struct tevent_context *ev,
- struct messaging_context *msg_ctx)
-{
- /*
- * Reload the printers first in the background process so that
- * newly added printers get default values created in the registry.
- *
- * This will block the process for some time (~1 sec per printer), but
- * it doesn't block smbd's servering clients.
- */
- reload_printers(ev, msg_ctx);
-
- message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
-}