printing: use housekeeping period that matches cache time
authorDavid Disseldorp <ddiss@samba.org>
Mon, 18 Apr 2016 16:48:42 +0000 (18:48 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 19 Apr 2016 07:37:14 +0000 (09:37 +0200)
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@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/printing/queue_process.c
source3/smbd/globals.c

index c9e55223b137526e2f9439a6b3ff8e770101177d..f51304ad9c7ab23704df6d926cad506eae1d427f 100644 (file)
@@ -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))) {
index 70805a1b2a570b97f3578a9ab0de0d20d2c6e1fe..6bc448b901d68fa0fc799405a6f0d02da8ac20eb 100644 (file)
@@ -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;
 
 /****************************************************************************