[PATCH 1/2] printing: use housekeeping period that matches cache time

David Disseldorp ddiss at samba.org
Mon Apr 18 16:48:42 UTC 2016


The printcap housekeeping callback is scheduled to run every 60 seconds,
and invokes pcap_cache_reload() to reload of the printcap cache *if* the
"printcap cache time" period has expired.

Given that pcap_cache_reload() invocation is the only job of the
housekeeping callback, it makes much more sense to schedule it every
"printcap cache time" seconds, rather than every 60 seconds.

Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/printing/queue_process.c | 21 ++++++++-------------
 source3/smbd/globals.c           |  1 -
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index c9e5522..f51304ad 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -157,20 +157,9 @@ static bool print_queue_housekeeping(const struct timeval *now, void *pvt)
 	struct printing_queue_housekeeping_state *state =
 		talloc_get_type_abort(pvt,
 		struct printing_queue_housekeeping_state);
-	time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
-	time_t t = time_mono(NULL);
 
 	DEBUG(5, ("print queue housekeeping\n"));
-
-	/* if periodic printcap rescan is enabled,
-	 * see if it's time to reload */
-	if ((printcap_cache_time != 0) &&
-	    (t >= (last_printer_reload_time + printcap_cache_time))) {
-		DEBUG( 3,( "Printcap cache time expired.\n"));
-		pcap_cache_reload(state->ev, state->msg,
-				  &reload_pcap_change_notify);
-		last_printer_reload_time = t;
-	}
+	pcap_cache_reload(state->ev, state->msg, &reload_pcap_change_notify);
 
 	return true;
 }
@@ -179,6 +168,7 @@ static bool printing_subsystem_queue_tasks(struct tevent_context *ev_ctx,
 					   struct messaging_context *msg_ctx)
 {
 	struct printing_queue_housekeeping_state *state;
+	uint32_t housekeeping_period = lp_printcap_cache_time();
 
 	state = talloc_zero(ev_ctx, struct printing_queue_housekeeping_state);
 	if (state == NULL) {
@@ -188,8 +178,13 @@ static bool printing_subsystem_queue_tasks(struct tevent_context *ev_ctx,
 	state->ev = ev_ctx;
 	state->msg = msg_ctx;
 
+	if (housekeeping_period == 0) {
+		DEBUG(4, ("background print queue housekeeping disabled\n"));
+		return true;
+	}
+
 	if (!(event_add_idle(ev_ctx, NULL,
-			     timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
+			     timeval_set(housekeeping_period, 0),
 			     "print_queue_housekeeping",
 			     print_queue_housekeeping,
 			     state))) {
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 70805a1..6bc448b9 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -46,7 +46,6 @@ unsigned mangle_prefix = 0;
 bool logged_ioctl_message = false;
 
 time_t last_smb_conf_reload_time = 0;
-time_t last_printer_reload_time = 0;
 pid_t background_lpq_updater_pid = -1;
 
 /****************************************************************************
-- 
2.6.6




More information about the samba-technical mailing list