From ff577762b9cb37355f9433850b2119a6411e21da Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Tue, 28 Dec 2010 14:55:01 +0100 Subject: s3-printing: remove old entries in pcap_cache_replace Callers of pcap_cache_replace() assume the existing printcap cache is replaced by the new values provided. This is not currently the case, old entries should be removed. --- source3/printing/pcap.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source3/printing/pcap.c') diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index be267bd116..7a733b1c3c 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -97,13 +97,28 @@ bool pcap_cache_loaded(void) return NT_STATUS_IS_OK(status); } -void pcap_cache_replace(const struct pcap_cache *pcache) +bool pcap_cache_replace(const struct pcap_cache *pcache) { const struct pcap_cache *p; + NTSTATUS status; + + status = printer_list_mark_reload(); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to mark printer list for reload!\n")); + return false; + } for (p = pcache; p; p = p->next) { pcap_cache_add(p->name, p->comment); } + + status = printer_list_clean_old(); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("Failed to cleanup printer list!\n")); + return false; + } + + return true; } void pcap_cache_reload(struct tevent_context *ev, @@ -175,7 +190,7 @@ void pcap_cache_reload(struct tevent_context *ev, done: DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error")); - if (pcap_reloaded) { + if ((pcap_reloaded) && (post_cache_fill_fn_handled == false)) { /* cleanup old entries only if the operation was successful, * otherwise keep around the old entries until we can * successfuly reaload */ @@ -183,8 +198,7 @@ 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)) { + if (post_cache_fill_fn != NULL) { post_cache_fill_fn(ev, msg_ctx); } } -- cgit