diff options
author | David Disseldorp <ddiss@samba.org> | 2014-07-23 14:42:00 +0200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2014-09-01 21:34:11 +0200 |
commit | 728e951923ab7a3f8a9e3dcf2179ef9132e668d1 (patch) | |
tree | e88235e6f1e0459bef3e6f437db0271ca6d13f97 /source3 | |
parent | 5a647c5258f57c93563a4e962aa712221874bf2d (diff) | |
download | samba-728e951923ab7a3f8a9e3dcf2179ef9132e668d1.tar.gz |
smbd: only reprocess printer_list.tdb if it changed
The per-client smbd printer share inventory is currently updated from
printer_list.tdb when a client enumerates printers, via EnumPrinters or
NetShareEnum.
printer_list.tdb is populated by the background print process, based on
the latest printcap values retrieved from the printing backend (e.g.
CUPS) at regular intervals.
This change ensures that per-client smbd processes don't reparse
printer_list.tdb if it hasn't been updated since the last enumeration.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652
Suggested-by: Volker Lendecke <vl@samba.org>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit a2182e03a061de6c1f111ce083cb5f668fe75e4e)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/server_reload.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c index 1d6f9c2911f..6b36e6844c9 100644 --- a/source3/smbd/server_reload.c +++ b/source3/smbd/server_reload.c @@ -31,6 +31,13 @@ #include "messages.h" #include "lib/param/loadparm.h" +/* + * The persistent pcap cache is populated by the background print process. Per + * client smbds should only reload their printer share inventories if this + * information has changed. Use reload_last_pcap_time to detect this. + */ +static time_t reload_last_pcap_time = 0; + static bool snum_is_shared_printer(int snum) { return (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum)); @@ -61,6 +68,20 @@ void delete_and_reload_printers(struct tevent_context *ev, const char *pname; const char *sname; NTSTATUS status; + bool ok; + time_t pcap_last_update; + + ok = pcap_cache_loaded(&pcap_last_update); + if (!ok) { + DEBUG(1, ("pcap cache not loaded\n")); + return; + } + + if (reload_last_pcap_time == pcap_last_update) { + DEBUG(5, ("skipping printer reload, already up to date.\n")); + return; + } + reload_last_pcap_time = pcap_last_update; /* Get pcap printers updated */ load_printers(ev, msg_ctx); |