num_children += 1;
}
+/****************************************************************************
+ Notify smbds of new printcap data
+**************************************************************************/
+static 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);
+}
+
static bool printer_housekeeping_fn(const struct timeval *now,
void *private_data)
{
return true;
}
+static void printing_sig_term_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ exit_server_cleanly("termination signal");
+}
+
+static void printing_sig_hup_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ struct messaging_context *msg_ctx = talloc_get_type_abort(
+ private_data, struct messaging_context);
+
+ DEBUG(1,("Reloading printers after SIGHUP\n"));
+ reload_pcap_change_notify(ev, msg_ctx);
+}
+
static pid_t background_lpq_updater_pid = -1;
/****************************************************************************
struct tevent_fd *fde;
int ret;
NTSTATUS status;
+ struct tevent_signal *se;
/* Child. */
DEBUG(5,("start_background_queue: background LPQ thread started\n"));
smb_panic("reinit_after_fork() failed");
}
- smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler(ev, msg_ctx);
+ se = tevent_add_signal(ev, ev, SIGTERM, 0,
+ printing_sig_term_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("failed to setup SIGTERM handler");
+ }
+ se = tevent_add_signal(ev, ev, SIGHUP, 0,
+ printing_sig_hup_handler,
+ msg_ctx);
+ if (se == NULL) {
+ smb_panic("failed to setup SIGHUP handler");
+ }
if (!serverid_register(procid_self(),
FLAG_MSG_GENERAL|FLAG_MSG_SMBD
/* The following definitions come from smbd/process.c */
void smbd_setup_sig_term_handler(void);
-void smbd_setup_sig_hup_handler(struct tevent_context *ev,
- struct messaging_context *msg_ctx);
bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
bool no_signing, uint32_t seqnum,
bool do_encrypt,
struct messaging_context *msg_ctx);
bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
bool test);
-void reload_pcap_change_notify(struct tevent_context *ev,
- struct messaging_context *msg_ctx);
void exit_server(const char *const explanation);
void exit_server_cleanly(const char *const explanation);
void exit_server_fault(void);
return(ret);
}
-
-/****************************************************************************
- Notify smbds of new printcap data
-**************************************************************************/
-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);
-}