num_children += 1;
}
+static bool printer_housekeeping_fn(const struct timeval *now,
+ void *private_data)
+{
+ static time_t last_pcap_reload_time = 0;
+ time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
+ time_t t = time_mono(NULL);
+
+ DEBUG(5, ("printer housekeeping\n"));
+
+ /* if periodic printcap rescan is enabled, see if it's time to reload */
+ if ((printcap_cache_time != 0)
+ && (t >= (last_pcap_reload_time + printcap_cache_time))) {
+ DEBUG( 3,( "Printcap cache time expired.\n"));
+ pcap_cache_reload(server_event_context(),
+ smbd_messaging_context(),
+ &reload_pcap_change_notify);
+ last_pcap_reload_time = t;
+ }
+
+ return true;
+}
+
static pid_t background_lpq_updater_pid = -1;
/****************************************************************************
smb_panic("tevent_add_fd() failed for pause_pipe");
}
+ if (!(event_add_idle(ev, NULL,
+ timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
+ "printer_housekeeping",
+ printer_housekeeping_fn,
+ NULL))) {
+ DEBUG(0, ("Could not add printing housekeeping event\n"));
+ exit(1);
+ }
+
DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
ret = tevent_loop_wait(ev);
/* should not be reached */
return true;
}
-static bool smbd_parent_housekeeping(const struct timeval *now, void *private_data)
-{
- time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
- time_t t = time_mono(NULL);
-
- DEBUG(5, ("parent 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(server_event_context(),
- smbd_messaging_context(),
- &reload_pcap_change_notify);
- last_printer_reload_time = t;
- }
-
- return true;
-}
-
/****************************************************************************
Open the socket communication.
****************************************************************************/
return false;
}
- if (!(event_add_idle(smbd_event_context(), NULL,
- timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
- "parent_housekeeping", smbd_parent_housekeeping,
- NULL))) {
- DEBUG(0, ("Could not add parent_housekeeping event\n"));
- return false;
- }
-
/* Listen to messages */
messaging_register(msg_ctx, NULL, MSG_SMB_SAM_SYNC, msg_sam_sync);
void reload_pcap_change_notify(struct tevent_context *ev,
struct messaging_context *msg_ctx)
{
+ /*
+ * Reload the printers first in the background process so that
+ * newly added printers get default values created in the registry.
+ *
+ * This will block the process for some time (~1 sec per printer), but
+ * it doesn't block smbd's servering clients.
+ */
+ reload_printers(ev, msg_ctx);
+
message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
}