printing: return last change time with pcap_cache_loaded()
authorDavid Disseldorp <ddiss@samba.org>
Wed, 23 Jul 2014 10:12:34 +0000 (12:12 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 2 Sep 2014 18:39:20 +0000 (20:39 +0200)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 30ce835670a6aeca6fb960ea7c4fe1b982bdd5b0)
[ddiss@samba.org: rebasead for 4.0 with swat]

source3/printing/load.c
source3/printing/pcap.c
source3/printing/pcap.h
source3/printing/queue_process.c
source3/printing/spoolssd.c
source3/web/swat.c

index 2ba3b2e106d854f4eb5901361aa351655ec4f804..238998d920d7d2b943b01734d4ef78c1e4394cf4 100644 (file)
@@ -65,7 +65,7 @@ load automatic printer services from pre-populated pcap cache
 void load_printers(struct tevent_context *ev,
                   struct messaging_context *msg_ctx)
 {
-       SMB_ASSERT(pcap_cache_loaded());
+       SMB_ASSERT(pcap_cache_loaded(NULL));
 
        add_auto_printers();
 
index 9c44584a4d2edb143d76086f021db4220a6c4403..c5524ad53dbfb3f46364a8d9a2fe154cc45a825e 100644 (file)
@@ -83,13 +83,19 @@ void pcap_cache_destroy_specific(struct pcap_cache **pp_cache)
        *pp_cache = NULL;
 }
 
-bool pcap_cache_loaded(void)
+bool pcap_cache_loaded(time_t *_last_change)
 {
        NTSTATUS status;
        time_t last;
 
        status = printer_list_get_last_refresh(&last);
-       return NT_STATUS_IS_OK(status);
+       if (!NT_STATUS_IS_OK(status)) {
+               return false;
+       }
+       if (_last_change != NULL) {
+               *_last_change = last;
+       }
+       return true;
 }
 
 bool pcap_cache_replace(const struct pcap_cache *pcache)
index 7dccf84b37497dbf18a2932fabef4f48567ddf59..8fc9e9de31c2aa570ed04fb65d7dbae2584b0a86 100644 (file)
@@ -35,7 +35,7 @@ struct pcap_cache;
 
 bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment, const char *location);
 void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
-bool pcap_cache_loaded(void);
+bool pcap_cache_loaded(time_t *_last_change);
 bool pcap_cache_replace(const struct pcap_cache *cache);
 void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, const char *, void *), void *);
 void pcap_printer_read_fn(void (*fn)(const char *, const char *, const char *, void *), void *);
index 0969c7bfb4f5c1d674a3d37ba5ce08c4f3295edc..78b44b8f5dc79985b4b8d226fd89a89b4d9c96ef 100644 (file)
@@ -387,7 +387,7 @@ void printing_subsystem_update(struct tevent_context *ev_ctx,
                               bool force)
 {
        if (background_lpq_updater_pid != -1) {
-               if (pcap_cache_loaded()) {
+               if (pcap_cache_loaded(NULL)) {
                        load_printers(ev_ctx, msg_ctx);
                }
                if (force) {
index a3f5f7633bf4d57f47965f9fbcd8f255feb29781..87d93ac8255a1c84d76a73fc5c8198148d485d76 100644 (file)
@@ -300,7 +300,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()) {
+       if (pcap_cache_loaded(NULL)) {
                load_printers(ev_ctx, msg_ctx);
        }
 
@@ -718,7 +718,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()) {
+       if (pcap_cache_loaded(NULL)) {
                load_printers(ev_ctx, msg_ctx);
        }
 
index cc90f21129788c1c231b947001294bc7f8c62994..640cd5d0862fb5285afb866565f54269ac9dd116 100644 (file)
@@ -594,7 +594,7 @@ static int save_reload(int snum)
                 return 0;
         }
        iNumNonAutoPrintServices = lp_numservices();
-       if (pcap_cache_loaded()) {
+       if (pcap_cache_loaded(NULL)) {
                struct tevent_context *ev_ctx;
                struct messaging_context *msg_ctx;
 
@@ -1595,7 +1595,7 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid)
        reopen_logs();
        load_interfaces();
        iNumNonAutoPrintServices = lp_numservices();
-       if (pcap_cache_loaded()) {
+       if (pcap_cache_loaded(NULL)) {
                struct tevent_context *ev_ctx;
                struct messaging_context *msg_ctx;