s3-printing: Force pcap reload when all ready
authorSimo Sorce <idra@samba.org>
Thu, 4 Aug 2011 12:56:01 +0000 (08:56 -0400)
committerAndreas Schneider <asn@samba.org>
Wed, 10 Aug 2011 16:14:05 +0000 (18:14 +0200)
This way we are sure the cache is primed properly and messages can be sent to
processes if necessary as all messaging has been set up.

Signed-off-by: Andreas Schneider <asn@samba.org>
source3/printing/queue_process.c
source3/printing/queue_process.h
source3/smbd/process.c
source3/smbd/server.c

index 5d18a08d63e0585e3c2eae83422b40ca369a7dea..82fd70d36d6222517de2b553d118679f158431cb 100644 (file)
@@ -295,9 +295,17 @@ bool printing_subsystem_init(struct tevent_context *ev_ctx,
 }
 
 void printing_subsystem_update(struct tevent_context *ev_ctx,
-                              struct messaging_context *msg_ctx)
+                              struct messaging_context *msg_ctx,
+                              bool force)
 {
-       if (background_lpq_updater_pid != -1) return;
+       if (background_lpq_updater_pid != -1) {
+               if (force) {
+                       /* Send a sighup to the background process.
+                        * this will force it to reload printers */
+                       kill(background_lpq_updater_pid, SIGHUP);
+               }
+               return;
+       }
 
        pcap_cache_reload(ev_ctx, msg_ctx, &reload_pcap_change_notify);
 }
index f0da726058d1b6100e7deb3d128407bee109e25d..5f282c44629921daf11b5c59765283c5b2cdfed6 100644 (file)
@@ -25,6 +25,7 @@ bool printing_subsystem_init(struct tevent_context *ev_ctx,
                             bool start_daemons,
                             bool background_queue);
 void printing_subsystem_update(struct tevent_context *ev_ctx,
-                              struct messaging_context *msg_ctx);
+                              struct messaging_context *msg_ctx,
+                              bool force);
 pid_t start_background_queue(struct tevent_context *ev,
                             struct messaging_context *msg);
index d96d5fb7e0135fc9f14eca70ab70a57541d94c34..f542dcd84f34ad500ce3c6ed4b57d002298828b2 100644 (file)
@@ -887,7 +887,7 @@ static void smbd_sig_hup_handler(struct tevent_context *ev,
        DEBUG(1,("Reloading services after SIGHUP\n"));
        reload_services(msg_ctx, smbd_server_conn->sock, False);
        if (am_parent) {
-               printing_subsystem_update(ev, msg_ctx);
+               printing_subsystem_update(ev, msg_ctx, true);
        }
 }
 
index ee406fdfafba2e91dc86658a1c3233fcbe8e4fe1..24d61483e25b0244ecc8b4920bfc3d2dd8793aaf 100644 (file)
@@ -64,7 +64,7 @@ static void smb_conf_updated(struct messaging_context *msg,
        change_to_root_user();
        reload_services(msg, smbd_server_conn->sock, False);
        if (am_parent) {
-               printing_subsystem_update(ev_ctx, msg);
+               printing_subsystem_update(ev_ctx, msg, false);
        }
 }
 
@@ -1260,6 +1260,10 @@ extern void build_options(bool screen);
        if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports))
                exit_server("open_sockets_smbd() failed");
 
+       /* force a printer update now that all messaging has been set up,
+        * before we allow clients to start connecting */
+       printing_subsystem_update(ev_ctx, msg_ctx, true);
+
        TALLOC_FREE(frame);
        /* make sure we always have a valid stackframe */
        frame = talloc_stackframe();