diff options
Diffstat (limited to 'source/smbd/process.c')
-rw-r--r-- | source/smbd/process.c | 90 |
1 files changed, 35 insertions, 55 deletions
diff --git a/source/smbd/process.c b/source/smbd/process.c index ffc731e42b3..5830af8f435 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -225,7 +225,8 @@ struct idle_event { void *private_data; }; -static void idle_event_handler(struct timed_event *te, +static void idle_event_handler(struct event_context *ctx, + struct timed_event *te, const struct timeval *now, void *private_data) { @@ -240,7 +241,8 @@ static void idle_event_handler(struct timed_event *te, return; } - event->te = add_timed_event(event, timeval_sum(now, &event->interval), + event->te = event_add_timed(smbd_event_context(), event, + timeval_sum(now, &event->interval), "idle_event_handler", idle_event_handler, event); @@ -267,11 +269,12 @@ struct idle_event *add_idle_event(TALLOC_CTX *mem_ctx, result->handler = handler; result->private_data = private_data; - result->te = add_timed_event(result, timeval_sum(&now, &interval), + result->te = event_add_timed(smbd_event_context(), result, + timeval_sum(&now, &interval), "idle_event_handler", idle_event_handler, result); if (result->te == NULL) { - DEBUG(0, ("add_timed_event failed\n")); + DEBUG(0, ("event_add_timed failed\n")); TALLOC_FREE(result); return NULL; } @@ -301,9 +304,6 @@ static void async_processing(fd_set *pfds) exit_server_cleanly("termination signal"); } - /* check for async change notify events */ - process_pending_change_notify_queue(0); - /* check for sighup processing */ if (reload_after_sighup) { change_to_root_user(); @@ -350,7 +350,7 @@ The timeout is in milliseconds static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) { - fd_set fds; + fd_set r_fds, w_fds; int selrtn; struct timeval to; int maxfd = 0; @@ -414,10 +414,11 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) } /* - * Setup the select read fd set. + * Setup the select fd sets. */ - FD_ZERO(&fds); + FD_ZERO(&r_fds); + FD_ZERO(&w_fds); /* * Ensure we process oplock break messages by preference. @@ -428,9 +429,9 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) * This is hideously complex - *MUST* be simplified for 3.0 ! JRA. */ - if (oplock_message_waiting(&fds)) { + if (oplock_message_waiting(&r_fds)) { DEBUG(10,("receive_message_or_smb: oplock_message is waiting.\n")); - async_processing(&fds); + async_processing(&r_fds); /* * After async processing we must go and do the select again, as * the state of the flag in fds for the server file descriptor is @@ -445,15 +446,17 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) */ { - struct timeval tmp; - struct timeval *tp = get_timed_events_timeout(&tmp); - - if (tp) { - to = timeval_min(&to, tp); - if (timeval_is_zero(&to)) { - /* Process a timed event now... */ - run_events(); - } + struct timeval now; + GetTimeOfDay(&now); + + event_add_to_select_args(smbd_event_context(), &now, + &r_fds, &w_fds, &to, &maxfd); + } + + if (timeval_is_zero(&to)) { + /* Process a timed event now... */ + if (run_events(smbd_event_context(), 0, NULL, NULL)) { + goto again; } } @@ -461,23 +464,26 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) int sav; START_PROFILE(smbd_idle); - maxfd = select_on_fd(smbd_server_fd(), maxfd, &fds); - maxfd = select_on_fd(change_notify_fd(), maxfd, &fds); - maxfd = select_on_fd(oplock_notify_fd(), maxfd, &fds); + maxfd = select_on_fd(smbd_server_fd(), maxfd, &r_fds); + maxfd = select_on_fd(oplock_notify_fd(), maxfd, &r_fds); - selrtn = sys_select(maxfd+1,&fds,NULL,NULL,&to); + selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&to); sav = errno; END_PROFILE(smbd_idle); errno = sav; } + if (run_events(smbd_event_context(), selrtn, &r_fds, &w_fds)) { + goto again; + } + /* if we get EINTR then maybe we have received an oplock signal - treat this as select returning 1. This is ugly, but is the best we can do until the oplock code knows more about signals */ if (selrtn == -1 && errno == EINTR) { - async_processing(&fds); + async_processing(&r_fds); /* * After async processing we must go and do the select again, as * the state of the flag in fds for the server file descriptor is @@ -505,8 +511,8 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) * sending us an oplock break message. JRA. */ - if (oplock_message_waiting(&fds)) { - async_processing(&fds); + if (oplock_message_waiting(&r_fds)) { + async_processing(&r_fds); /* * After async processing we must go and do the select again, as * the state of the flag in fds for the server file descriptor is @@ -515,19 +521,6 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) goto again; } - if ((change_notify_fd() >= 0) && FD_ISSET(change_notify_fd(), &fds)) { - - process_pending_change_notify_queue((time_t)0); - - /* - * Same comment as for oplock processing applies here. We - * might have done I/O on the client socket. - */ - - goto again; - } - - return receive_smb(smbd_server_fd(), buffer, 0); } @@ -1240,16 +1233,9 @@ int chain_reply(char *inbuf,char *outbuf,int size,int bufsize) static int setup_select_timeout(void) { int select_timeout; - int t; select_timeout = blocking_locks_timeout_ms(SMBD_SELECT_TIMEOUT*1000); - t = change_notify_timeout(); - DEBUG(10, ("change_notify_timeout: %d\n", t)); - if (t != -1) { - select_timeout = MIN(select_timeout, t*1000); - } - if (print_notify_messages_pending()) { select_timeout = MIN(select_timeout, 1000); } @@ -1448,12 +1434,6 @@ machine %s in domain %s.\n", global_myname(), lp_workgroup())); update_monitored_printq_cache(); /* - * Check to see if we have any change notifies - * outstanding on the queue. - */ - process_pending_change_notify_queue(t); - - /* * Now we are root, check if the log files need pruning. * Force a log file check. */ @@ -1603,7 +1583,7 @@ void smbd_process(void) num_smbs = 0; /* Reset smb counter. */ } - run_events(); + run_events(smbd_event_context(), 0, NULL, NULL); #if defined(DEVELOPER) clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size); |