diff options
Diffstat (limited to 'source3/smbd/process.c')
-rw-r--r-- | source3/smbd/process.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 929471a48c..2a52da12b3 100644 --- a/source3/smbd/process.c +++ b/source3/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; } @@ -350,7 +353,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 +417,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 +432,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 +449,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 +467,27 @@ 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(change_notify_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 +515,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,7 +525,8 @@ 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)) { + if ((change_notify_fd() >= 0) && FD_ISSET(change_notify_fd(), + &r_fds)) { process_pending_change_notify_queue((time_t)0); @@ -1603,7 +1614,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); |