diff options
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/notify.c | 20 | ||||
-rw-r--r-- | source3/printing/printing.c | 58 |
2 files changed, 54 insertions, 24 deletions
diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 860a400d64..d478b86f91 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -34,7 +34,10 @@ static struct notify_queue { size_t buflen; } *notify_queue_head = NULL; -static struct timed_event *notify_event; +static struct tevent_timer *notify_event; + +static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, + size_t *p_num_pids, pid_t **pp_pid_list); static bool create_send_ctx(void) { @@ -63,7 +66,7 @@ int print_queue_snum(const char *qname) Used to decide if we need a short select timeout. *******************************************************************/ -bool print_notify_messages_pending(void) +static bool print_notify_messages_pending(void) { return (notify_queue_head != NULL); } @@ -219,10 +222,10 @@ void print_notify_send_messages(struct messaging_context *msg_ctx, Event handler to send the messages. *******************************************************************/ -static void print_notify_event_send_messages(struct event_context *event_ctx, - struct timed_event *te, - struct timeval now, - void *private_data) +static void print_notify_event_send_messages(struct tevent_context *event_ctx, + struct tevent_timer *te, + struct timeval now, + void *private_data) { /* Remove this timed event handler. */ TALLOC_FREE(notify_event); @@ -324,7 +327,7 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer)); if ((notify_event == NULL) && (smbd_event_context() != NULL)) { /* Add an event for 1 second's time to send this queue. */ - notify_event = event_add_timed(smbd_event_context(), NULL, + notify_event = tevent_add_timer(smbd_event_context(), NULL, timeval_current_ofs(1,0), print_notify_event_send_messages, NULL); } @@ -535,7 +538,8 @@ void notify_printer_byname( const char *printername, uint32 change, const char * messages on this print queue. Used in printing/notify to send the messages. ****************************************************************************/ -bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t *p_num_pids, pid_t **pp_pid_list) +static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, + size_t *p_num_pids, pid_t **pp_pid_list) { struct tdb_print_db *pdb = NULL; TDB_CONTEXT *tdb = NULL; 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; + } } } |