summaryrefslogtreecommitdiff
path: root/source3/printing/printing.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-01-21 07:37:07 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-22 12:37:32 +0100
commit7a07fcdc1e1f01483ae9d509a9d42eea4d454529 (patch)
treea40ec852961fdeeeb5ee5ce993d120cef4caf9e5 /source3/printing/printing.c
parentcf53e48fecf2a4410ff641eb6e0edd8578cccb15 (diff)
downloadsamba-7a07fcdc1e1f01483ae9d509a9d42eea4d454529.tar.gz
samba-7a07fcdc1e1f01483ae9d509a9d42eea4d454529.tar.bz2
samba-7a07fcdc1e1f01483ae9d509a9d42eea4d454529.zip
s3:printing: handle tevent_context events in the sys_select() call
metze
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r--source3/printing/printing.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index fffe9178cf..bb29380007 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1439,15 +1439,47 @@ void start_background_queue(void)
DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
while (1) {
- fd_set pause_fds;
- int pause_select;
+ fd_set r_fds, w_fds;
+ int ret;
+ struct timeval to;
+ int maxfd = 0;
- FD_ZERO(&pause_fds);
- FD_SET(pause_pipe[1], &pause_fds);
- pause_select = sys_select(pause_pipe[1]+1, &pause_fds, NULL, NULL, NULL);
- /* If pause_pipe[0] is closed it means the parent smbd
+ /* Process a signal and timed events now... */
+ if (run_events(smbd_event_context(), 0, NULL, NULL)) {
+ continue;
+ }
+
+ to.tv_sec = SMBD_SELECT_TIMEOUT;
+ to.tv_usec = 0;
+
+ /*
+ * Setup the select fd sets.
+ */
+
+ FD_ZERO(&r_fds);
+ FD_ZERO(&w_fds);
+
+ /*
+ * Are there any timed events waiting ? If so, ensure we don't
+ * select for longer than it would take to wait for them.
+ */
+
+ {
+ struct timeval now;
+ GetTimeOfDay(&now);
+
+ event_add_to_select_args(smbd_event_context(), &now,
+ &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);
+
+ /* If pause_pipe[1] is closed it means the parent smbd
* and children exited or aborted. */
- if (pause_select == 1) {
+ if (ret == 1 && FD_ISSET(pause_pipe[1], &r_fds)) {
exit_server_cleanly(NULL);
}
@@ -1464,15 +1496,9 @@ void start_background_queue(void)
reload_after_sighup = 0;
}
- /* now check for messages */
-
- DEBUG(10,("start_background_queue: background LPQ thread got a message\n"));
- message_dispatch(smbd_messaging_context());
-
- /* process any pending print change notify messages */
-
- print_notify_send_messages(smbd_messaging_context(),
- 0);
+ if (run_events(smbd_event_context(), ret, &r_fds, &w_fds)) {
+ continue;
+ }
}
}