diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-03-16 14:56:11 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-03-18 07:00:39 +0100 |
commit | 339ea0503d5ce3bf85cf61528956345c73c668c6 (patch) | |
tree | 51363e313491d5208f365b8d43bcc6350b6e9e41 | |
parent | 445b37f4f35ff4256c46dbacc2d3b3a1e47e62b2 (diff) | |
download | samba-339ea0503d5ce3bf85cf61528956345c73c668c6.tar.gz samba-339ea0503d5ce3bf85cf61528956345c73c668c6.tar.bz2 samba-339ea0503d5ce3bf85cf61528956345c73c668c6.zip |
s3:printing: use a fd event to monitor the pipe to the parent
metze
-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); /* |