s3-spoolss: do not call pcap_cache_reload() directly
authorSimo Sorce <idra@samba.org>
Wed, 10 Aug 2011 13:20:24 +0000 (09:20 -0400)
committerAndreas Schneider <asn@samba.org>
Wed, 10 Aug 2011 16:14:05 +0000 (18:14 +0200)
The background queue process is repsonsible for that.
Just reload printers if necessary or wait for a message from bq to do that.

Signed-off-by: Andreas Schneider <asn@samba.org>
source3/printing/spoolssd.c

index 77846c28ae931a0306258fa0505aebe28ef7e7aa..3d7494921c4fa1596147fb77ba1bf30aefac71c9 100644 (file)
@@ -25,6 +25,7 @@
 #include "printing/nt_printing_migrate_internal.h"
 #include "printing/queue_process.h"
 #include "printing/pcap.h"
+#include "printing/load.h"
 #include "ntdomain.h"
 #include "librpc/gen_ndr/srv_winreg.h"
 #include "librpc/gen_ndr/srv_spoolss.h"
@@ -359,6 +360,14 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
                           pcap_updated);
 
+       /* As soon as messaging is up check if pcap has been loaded already.
+        * If so then we probably missed a message and should load_printers()
+        * ourselves. If pcap has not been loaded yet, then ignore, we will get
+        * a message as soon as the bq process completes the reload. */
+       if (pcap_cache_loaded()) {
+               load_printers(ev_ctx, msg_ctx);
+       }
+
        /* try to reinit rpc queues */
        spoolss_cb.init = spoolss_init_cb;
        spoolss_cb.shutdown = spoolss_shutdown_cb;
@@ -378,8 +387,6 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
                return false;
        }
 
-       pcap_cache_reload(ev_ctx, msg_ctx, &update_pcap);
-
        return true;
 }
 
@@ -782,9 +789,6 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
        BlockSignals(false, SIGTERM);
        BlockSignals(false, SIGHUP);
 
-       /* Publish nt printers, this requires a working winreg pipe */
-       pcap_cache_reload(ev_ctx, msg_ctx, &reload_printers);
-
        /* always start the backgroundqueue listner in spoolssd */
        bq_logfile = get_bq_logfile();
        pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
@@ -834,6 +838,14 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
        messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
                           pcap_updated);
 
+       /* As soon as messaging is up check if pcap has been loaded already.
+        * If so then we probably missed a message and should load_printers()
+        * ourselves. If pcap has not been loaded yet, then ignore, we will get
+        * a message as soon as the bq process completes the reload. */
+       if (pcap_cache_loaded()) {
+               load_printers(ev_ctx, msg_ctx);
+       }
+
        mem_ctx = talloc_new(NULL);
        if (mem_ctx == NULL) {
                exit(1);