mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
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.
This commit is contained in:
parent
0b188e7784
commit
ff577762b9
@ -97,13 +97,28 @@ bool pcap_cache_loaded(void)
|
|||||||
return NT_STATUS_IS_OK(status);
|
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;
|
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) {
|
for (p = pcache; p; p = p->next) {
|
||||||
pcap_cache_add(p->name, p->comment);
|
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,
|
void pcap_cache_reload(struct tevent_context *ev,
|
||||||
@ -175,7 +190,7 @@ void pcap_cache_reload(struct tevent_context *ev,
|
|||||||
done:
|
done:
|
||||||
DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
|
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,
|
/* cleanup old entries only if the operation was successful,
|
||||||
* otherwise keep around the old entries until we can
|
* otherwise keep around the old entries until we can
|
||||||
* successfuly reaload */
|
* successfuly reaload */
|
||||||
@ -183,8 +198,7 @@ done:
|
|||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(0, ("Failed to cleanup printer list!\n"));
|
DEBUG(0, ("Failed to cleanup printer list!\n"));
|
||||||
}
|
}
|
||||||
if ((post_cache_fill_fn_handled == false)
|
if (post_cache_fill_fn != NULL) {
|
||||||
&& (post_cache_fill_fn != NULL)) {
|
|
||||||
post_cache_fill_fn(ev, msg_ctx);
|
post_cache_fill_fn(ev, msg_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, cons
|
|||||||
void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
|
void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
|
||||||
bool pcap_cache_add(const char *name, const char *comment);
|
bool pcap_cache_add(const char *name, const char *comment);
|
||||||
bool pcap_cache_loaded(void);
|
bool pcap_cache_loaded(void);
|
||||||
void pcap_cache_replace(const struct pcap_cache *cache);
|
bool pcap_cache_replace(const struct pcap_cache *cache);
|
||||||
void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
|
void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
|
||||||
void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
|
void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
|
||||||
|
|
||||||
|
@ -552,15 +552,18 @@ static void cups_async_callback(struct event_context *event_ctx,
|
|||||||
|
|
||||||
TALLOC_FREE(frame);
|
TALLOC_FREE(frame);
|
||||||
if (tmp_pcap_cache) {
|
if (tmp_pcap_cache) {
|
||||||
|
bool ret;
|
||||||
/* We got a namelist, replace our local cache. */
|
/* We got a namelist, replace our local cache. */
|
||||||
pcap_cache_destroy_specific(&local_pcap_copy);
|
pcap_cache_destroy_specific(&local_pcap_copy);
|
||||||
local_pcap_copy = tmp_pcap_cache;
|
local_pcap_copy = tmp_pcap_cache;
|
||||||
|
|
||||||
/* And the systemwide pcap cache. */
|
/* And the systemwide pcap cache. */
|
||||||
pcap_cache_replace(local_pcap_copy);
|
ret = pcap_cache_replace(local_pcap_copy);
|
||||||
|
if (!ret)
|
||||||
|
DEBUG(0, ("failed to replace pcap cache\n"));
|
||||||
|
|
||||||
/* Caller may have requested post cache fill callback */
|
/* Caller may have requested post cache fill callback */
|
||||||
if (cb_args->post_cache_fill_fn != NULL) {
|
if (ret && cb_args->post_cache_fill_fn != NULL) {
|
||||||
cb_args->post_cache_fill_fn(cb_args->event_ctx,
|
cb_args->post_cache_fill_fn(cb_args->event_ctx,
|
||||||
cb_args->msg_ctx);
|
cb_args->msg_ctx);
|
||||||
}
|
}
|
||||||
@ -611,10 +614,6 @@ bool cups_cache_reload(struct tevent_context *ev,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Replace the system cache with our
|
|
||||||
* local copy. */
|
|
||||||
pcap_cache_replace(local_pcap_copy);
|
|
||||||
|
|
||||||
DEBUG(10,("cups_cache_reload: async read on fd %d\n",
|
DEBUG(10,("cups_cache_reload: async read on fd %d\n",
|
||||||
*p_pipe_fd ));
|
*p_pipe_fd ));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user