diff options
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r-- | source3/printing/printing.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 71c634442b..7dd5e48b1a 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1387,6 +1387,18 @@ static void print_queue_receive(struct messaging_context *msg, return; } +static void printing_pause_fd_handler(struct tevent_context *ev, + struct tevent_fd *fde, + uint16_t flags, + void *private_data) +{ + /* + * If pause_pipe[1] is closed it means the parent smbd + * and children exited or aborted. + */ + exit_server_cleanly(NULL); +} + static pid_t background_lpq_updater_pid = -1; /**************************************************************************** @@ -1415,6 +1427,8 @@ void start_background_queue(void) } if(background_lpq_updater_pid == 0) { + struct tevent_fd *fde; + /* Child. */ DEBUG(5,("start_background_queue: background LPQ thread started\n")); @@ -1440,6 +1454,15 @@ void start_background_queue(void) messaging_register(smbd_messaging_context(), NULL, MSG_PRINTER_UPDATE, print_queue_receive); + fde = tevent_add_fd(smbd_event_context(), smbd_event_context(), + pause_pipe[1], TEVENT_FD_READ, + printing_pause_fd_handler, + NULL); + if (!fde) { + DEBUG(0,("tevent_add_fd() failed for pause_pipe\n")); + smb_panic("tevent_add_fd() failed for pause_pipe"); + } + DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n")); while (1) { fd_set r_fds, w_fds; @@ -1475,9 +1498,6 @@ void start_background_queue(void) &r_fds, &w_fds, &to, &maxfd); } - FD_SET(pause_pipe[1], &r_fds); - maxfd = MAX(pause_pipe[1], maxfd); - ret = sys_select(maxfd, &r_fds, &w_fds, NULL, &to); /* |