From 54aaa5a58c91df4054c3cbaa238c6a83bbfb2eb7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 10 Aug 2011 09:20:24 -0400 Subject: s3-spoolss: do not call pcap_cache_reload() directly 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 --- source3/printing/spoolssd.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index 77846c28ae..3d7494921c 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -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); -- cgit