printing: add sighup and conf change handlers
authorDavid Disseldorp <ddiss@samba.org>
Thu, 14 Feb 2013 16:02:08 +0000 (17:02 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sun, 7 Apr 2013 19:27:20 +0000 (21:27 +0200)
The background printing process is now responsible for all printcap
cache updates, which should be done on SIGHUP and configuration change.

source3/printing/printing.c
source3/smbd/process.c
source3/smbd/proto.h
source3/smbd/server.c

index 21f318c764babe1590c7277d4fe732a762c3fbd0..780afcfedb972c1dd0b2244a2b53106452323c86 100644 (file)
@@ -1717,9 +1717,22 @@ static void printing_sig_hup_handler(struct tevent_context *ev,
                private_data, struct messaging_context);
 
        DEBUG(1,("Reloading printers after SIGHUP\n"));
-       reload_pcap_change_notify(ev, msg_ctx);
+       pcap_cache_reload(ev, msg_ctx,
+                         &reload_pcap_change_notify);
 }
 
+static void printing_conf_updated(struct messaging_context *msg,
+                                 void *private_data,
+                                 uint32_t msg_type,
+                                 struct server_id server_id,
+                                 DATA_BLOB *data)
+{
+       DEBUG(5,("Reloading printers after conf change\n"));
+       pcap_cache_reload(messaging_event_context(msg), msg,
+                         &reload_pcap_change_notify);
+}
+
+
 static pid_t background_lpq_updater_pid = -1;
 
 /****************************************************************************
@@ -1795,6 +1808,8 @@ void start_background_queue(struct tevent_context *ev,
 
                messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
                                   print_queue_receive);
+               messaging_register(msg_ctx, NULL, MSG_SMB_CONF_UPDATED,
+                                  printing_conf_updated);
 
                fde = tevent_add_fd(ev, ev, pause_pipe[1], TEVENT_FD_READ,
                                    printing_pause_fd_handler,
index b93b9599fb545808d3d6e96f4991a6ccb8e461c3..f43005dda3ad8526b5a58b188bb05df69de95095 100644 (file)
@@ -921,56 +921,6 @@ 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)
-{
-       struct messaging_context *msg_ctx = talloc_get_type_abort(
-               private_data, struct messaging_context);
-       change_to_root_user();
-       DEBUG(1,("Reloading services after SIGHUP\n"));
-       reload_services(msg_ctx, smbd_server_conn->sock, False);
-}
-
-void smbd_setup_sig_hup_handler(struct tevent_context *ev,
-                               struct messaging_context *msg_ctx)
-{
-       struct tevent_signal *se;
-
-       se = tevent_add_signal(ev, ev, SIGHUP, 0, smbd_sig_hup_handler,
-                              msg_ctx);
-       if (!se) {
-               exit_server("failed to setup SIGHUP handler");
-       }
-}
-
 static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn)
 {
        int timeout;
index 2baa58da981d6cea400ca9b3508dd2d26bd9f778..3b0f817264849a8a9585481af0cff320f33e1e07 100644 (file)
@@ -769,7 +769,6 @@ NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
 
 /* The following definitions come from smbd/process.c  */
 
-void smbd_setup_sig_term_handler(void);
 bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
                  bool no_signing, uint32_t seqnum,
                  bool do_encrypt,
index 4a4a006c0c1be0c756ec1272e014577312d85bad..a08131f9a7f5bda8caaaf094018a04d8d5cea94c 100644 (file)
@@ -108,7 +108,7 @@ static void smb_conf_updated(struct messaging_context *msg,
                  "updated. Reloading.\n"));
        change_to_root_user();
        reload_services(msg, smbd_server_conn->sock, False);
-       reload_printers(ev_ctx, msg);
+       /* printer reload triggered by background printing process */
 }
 
 /*******************************************************************
@@ -129,6 +129,57 @@ static void smb_pcap_updated(struct messaging_context *msg,
        reload_printers(ev_ctx, msg);
 }
 
+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");
+}
+
+static 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)
+{
+       struct messaging_context *msg_ctx = talloc_get_type_abort(
+               private_data, struct messaging_context);
+       change_to_root_user();
+       DEBUG(1,("Reloading services after SIGHUP\n"));
+       reload_services(msg_ctx, smbd_server_conn->sock, false);
+}
+
+static void smbd_setup_sig_hup_handler(struct tevent_context *ev,
+                                      struct messaging_context *msg_ctx)
+{
+       struct tevent_signal *se;
+
+       se = tevent_add_signal(ev, ev, SIGHUP, 0, smbd_sig_hup_handler,
+                              msg_ctx);
+       if (!se) {
+               exit_server("failed to setup SIGHUP handler");
+       }
+}
+
+
 /*******************************************************************
  Delete a statcache entry.
  ********************************************************************/