printing: drop pcap_cache_loaded() guard around load_printers()
authorDavid Disseldorp <ddiss@samba.org>
Tue, 29 Jan 2019 00:50:15 +0000 (01:50 +0100)
committerNoel Power <npower@samba.org>
Fri, 1 Feb 2019 15:08:25 +0000 (16:08 +0100)
Add the pcap_cache_loaded() check to load_printers() and return early
if it returns false. This simplifies callers in preparation for checking
lp_load_printers() in the printcap cache update code-path.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13766

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/printing/load.c
source3/printing/queue_process.c
source3/printing/spoolssd.c

index 51495f970db6217af7bf284b0753a25cba487899..7e25d5a91c71c07bffcf48bb2a39716ef50b8350 100644 (file)
@@ -64,7 +64,9 @@ load automatic printer services from pre-populated pcap cache
 ***************************************************************************/
 void load_printers(void)
 {
-       SMB_ASSERT(pcap_cache_loaded(NULL));
+       if (!pcap_cache_loaded(NULL)) {
+               return;
+       }
 
        add_auto_printers();
 
index 1d60f259a867b3f0f112637222d00a4c0a6c65da..197bde0108660c0b24ca56b86918f71c3e1981a7 100644 (file)
@@ -483,9 +483,7 @@ void printing_subsystem_update(struct tevent_context *ev_ctx,
                               bool force)
 {
        if (background_lpq_updater_pid != -1) {
-               if (pcap_cache_loaded(NULL)) {
-                       load_printers();
-               }
+               load_printers();
                if (force) {
                        /* Send a sighup to the background process.
                         * this will force it to reload printers */
index c029f1a11d5cdee99fe28c9acf15b62d40aededf..1809679ebca3259f8d44746ae5ad59c3b972e2df 100644 (file)
@@ -288,9 +288,7 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
         * 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(NULL)) {
-               load_printers();
-       }
+       load_printers();
 
        /* try to reinit rpc queues */
        spoolss_cb.init = spoolss_init_cb;
@@ -699,9 +697,7 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
         * If pcap has not been loaded yet, then ignore, as we will reload on
         * client enumeration anyway.
         */
-       if (pcap_cache_loaded(NULL)) {
-               load_printers();
-       }
+       load_printers();
 
        mem_ctx = talloc_new(NULL);
        if (mem_ctx == NULL) {