{
change_to_root_user();
lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
- reload_printers(ev, msg);
+ load_printers(ev, msg);
spoolss_reopen_logs(spoolss_child_id);
if (spoolss_child_id == 0) {
struct messaging_context *msg_ctx)
{
change_to_root_user();
- reload_printers(ev_ctx, msg_ctx);
+ delete_and_reload_printers(ev_ctx, msg_ctx);
}
static void pcap_updated(struct messaging_context *msg,
/* Children */
-struct spoolss_chld_sig_hup_ctx {
- struct messaging_context *msg_ctx;
- struct pf_worker_data *pf;
-};
-
static void spoolss_chld_sig_hup_handler(struct tevent_context *ev,
struct tevent_signal *se,
int signum,
void *siginfo,
void *pvt)
{
- struct spoolss_chld_sig_hup_ctx *shc;
-
- shc = talloc_get_type_abort(pvt, struct spoolss_chld_sig_hup_ctx);
+ struct messaging_context *msg_ctx;
- /* avoid wasting CPU cycles if we are going to exit soon anyways */
- if (shc->pf != NULL &&
- shc->pf->cmds == PF_SRV_MSG_EXIT) {
- return;
- }
+ msg_ctx = talloc_get_type_abort(pvt, struct messaging_context);
change_to_root_user();
DEBUG(1,("Reloading printers after SIGHUP\n"));
- reload_printers(ev, shc->msg_ctx);
+ load_printers(ev, msg_ctx);
spoolss_reopen_logs(spoolss_child_id);
}
struct messaging_context *msg_ctx,
struct pf_worker_data *pf)
{
- struct spoolss_chld_sig_hup_ctx *shc;
struct tevent_signal *se;
- shc = talloc(ev_ctx, struct spoolss_chld_sig_hup_ctx);
- if (!shc) {
- DEBUG(1, ("failed to setup SIGHUP handler"));
- return false;
- }
- shc->pf = pf;
- shc->msg_ctx = msg_ctx;
-
se = tevent_add_signal(ev_ctx,
ev_ctx,
SIGHUP, 0,
spoolss_chld_sig_hup_handler,
- shc);
+ msg_ctx);
if (!se) {
DEBUG(1, ("failed to setup SIGHUP handler"));
return false;
return true;
}
+static void parent_ping(struct messaging_context *msg_ctx,
+ void *private_data,
+ uint32_t msg_type,
+ struct server_id server_id,
+ DATA_BLOB *data)
+{
+
+ /* The fact we received this message is enough to let make the event
+ * loop if it was idle. spoolss_children_main will cycle through
+ * spoolss_next_client at least once. That function will take whatever
+ * action is necessary */
+
+ DEBUG(10, ("Got message that the parent changed status.\n"));
+ return;
+}
+
static bool spoolss_child_init(struct tevent_context *ev_ctx,
int child_id, struct pf_worker_data *pf)
{
NTSTATUS status;
struct rpc_srv_callbacks spoolss_cb;
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = messaging_init(NULL, ev_ctx);
bool ok;
status = reinit_after_fork(msg_ctx, ev_ctx,
- procid_self(), true);
+ true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
smb_panic("reinit_after_fork() failed");
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);
/* 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()
extern pid_t background_lpq_updater_pid;
static char *bq_logfile;
-static void check_updater_child(void)
+static void check_updater_child(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
{
int status;
pid_t pid;
pid = sys_waitpid(background_lpq_updater_pid, &status, WNOHANG);
if (pid > 0) {
DEBUG(2, ("The background queue child died... Restarting!\n"));
- pid = start_background_queue(server_event_context(),
- server_messaging_context(),
- bq_logfile);
+ pid = start_background_queue(ev_ctx, msg_ctx, bq_logfile);
background_lpq_updater_pid = pid;
}
}
pfh_manage_pool(ev_ctx, msg_ctx, &pf_spoolss_cfg, spoolss_pool);
/* also check if the updater child is alive and well */
- check_updater_child();
+ check_updater_child(ev_ctx, msg_ctx);
}
static bool spoolssd_setup_children_monitor(struct tevent_context *ev_ctx,
status = reinit_after_fork(msg_ctx,
ev_ctx,
- procid_self(), true);
+ true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
smb_panic("reinit_after_fork() failed");