summaryrefslogtreecommitdiff
path: root/source3/printing/pcap.c
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2010-12-19 19:52:08 +0100
committerJeremy Allison <jra@samba.org>2011-01-07 15:37:39 -0800
commit04248c2cfaa5a1728ef58fc8ca231fd1309ca694 (patch)
tree81e3be76291d3fdbf5f1e29869c6ef82f7305193 /source3/printing/pcap.c
parent3a14c97459ea21f4a3ecefabfd676cb9839a162f (diff)
downloadsamba-04248c2cfaa5a1728ef58fc8ca231fd1309ca694.tar.gz
samba-04248c2cfaa5a1728ef58fc8ca231fd1309ca694.tar.bz2
samba-04248c2cfaa5a1728ef58fc8ca231fd1309ca694.zip
s3-printing: reload shares after pcap cache fill
Since commit eada8f8a, updates to the cups pcap cache are performed asynchronously - cups_cache_reload() forks a child process to request cups printer information and notify the parent smbd on completion. Currently printer shares are reloaded immediately following the call to cups_cache_reload(), this occurs prior to smbd receiving new cups pcap information from the child process. Such behaviour can result in stale print shares as outlined in bug 7836. This fix ensures print shares are only reloaded after new pcap data has been received. Pair-Programmed-With: Lars Müller <lars@samba.org>
Diffstat (limited to 'source3/printing/pcap.c')
-rw-r--r--source3/printing/pcap.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 1b8f46d8e7..be267bd116 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -107,11 +107,14 @@ void pcap_cache_replace(const struct pcap_cache *pcache)
}
void pcap_cache_reload(struct tevent_context *ev,
- struct messaging_context *msg_ctx)
+ struct messaging_context *msg_ctx,
+ void (*post_cache_fill_fn)(struct tevent_context *,
+ struct messaging_context *))
{
const char *pcap_name = lp_printcapname();
bool pcap_reloaded = False;
NTSTATUS status;
+ bool post_cache_fill_fn_handled = false;
DEBUG(3, ("reloading printcap cache\n"));
@@ -135,7 +138,13 @@ void pcap_cache_reload(struct tevent_context *ev,
#ifdef HAVE_CUPS
if (strequal(pcap_name, "cups")) {
- pcap_reloaded = cups_cache_reload(ev, msg_ctx);
+ pcap_reloaded = cups_cache_reload(ev, msg_ctx,
+ post_cache_fill_fn);
+ /*
+ * cups_cache_reload() is async and calls post_cache_fill_fn()
+ * on successful completion
+ */
+ post_cache_fill_fn_handled = true;
goto done;
}
#endif
@@ -174,6 +183,10 @@ done:
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to cleanup printer list!\n"));
}
+ if ((post_cache_fill_fn_handled == false)
+ && (post_cache_fill_fn != NULL)) {
+ post_cache_fill_fn(ev, msg_ctx);
+ }
}
return;