From: David Disseldorp Date: Mon, 18 Apr 2016 16:48:42 +0000 (+0200) Subject: printing: use housekeeping period that matches cache time X-Git-Tag: talloc-2.1.7~221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b27c976e2e958998bb17f9b443de3962276bbd4e;p=thirdparty%2Fsamba.git printing: use housekeeping period that matches cache time 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 Reviewed-by: Andreas Schneider --- diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index c9e55223b13..f51304ad9c7 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 70805a1b2a5..6bc448b901d 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; /****************************************************************************