summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-07-11 17:00:05 +0200
committerAndreas Schneider <asn@cryptomilk.org>2014-08-08 14:10:38 +0200
commit4f4501ac1f35ab15f25d207c0d33e7c4d1abdf38 (patch)
tree13a9ffcdebbdc254b8305b1f24943a66ed49a569 /source3/printing
parent1e83435eac2cef03fccb4cf69ef5e0bfbd710410 (diff)
downloadsamba-4f4501ac1f35ab15f25d207c0d33e7c4d1abdf38.tar.gz
printing: only reload printer shares on client enum
Currently, automatic printer share updates are handled in the following way: - Background printer process (BPP) forked on startup - Parent smbd and per-client children await MSG_PRINTER_PCAP messages - BPP periodically polls the printing backend for printcap data - printcap data written to printer_list.tdb - MSG_PRINTER_PCAP sent to all smbd processes following update - smbd processes all read the latest printer_list.tdb data, and update their share listings This procedure is not scalable, as all smbd processes hit printer_list.tdb in parallel, resulting in a large spike in CPU usage. This change sees smbd processes only update their printer share lists only when a client asks for this information, e.g. via NetShareEnum or EnumPrinters. 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>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/spoolssd.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index f181fcc3f2f..afb8f4fd2fe 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -132,27 +132,6 @@ static void smb_conf_updated(struct messaging_context *msg,
update_conf(ev_ctx, msg);
}
-static void update_pcap(struct tevent_context *ev_ctx,
- struct messaging_context *msg_ctx)
-{
- change_to_root_user();
- delete_and_reload_printers(ev_ctx, msg_ctx);
-}
-
-static void pcap_updated(struct messaging_context *msg,
- void *private_data,
- uint32_t msg_type,
- struct server_id server_id,
- DATA_BLOB *data)
-{
- struct tevent_context *ev_ctx;
-
- ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
-
- DEBUG(10, ("Got message that pcap updated. Reloading.\n"));
- update_pcap(ev_ctx, msg);
-}
-
static void spoolss_sig_term_handler(struct tevent_context *ev,
struct tevent_signal *se,
int signum,
@@ -318,8 +297,6 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
messaging_register(msg_ctx, ev_ctx,
MSG_SMB_CONF_UPDATED, smb_conf_updated);
- messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
- pcap_updated);
messaging_register(msg_ctx, ev_ctx,
MSG_PREFORK_PARENT_EVENT, parent_ping);
@@ -739,15 +716,14 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
MSG_SMB_CONF_UPDATED, smb_conf_updated);
messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
print_queue_forward);
- messaging_register(msg_ctx, ev_ctx, MSG_PRINTER_PCAP,
- pcap_updated);
messaging_register(msg_ctx, ev_ctx,
MSG_PREFORK_CHILD_EVENT, child_ping);
- /* As soon as messaging is up check if pcap has been loaded already.
- * 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. */
+ /*
+ * As soon as messaging is up check if pcap has been loaded already.
+ * If pcap has not been loaded yet, then ignore, as we will reload on
+ * client enumeration anyway.
+ */
if (pcap_cache_loaded()) {
load_printers(ev_ctx, msg_ctx);
}