From 048f8dba141c2f9898aad67e09925f03394a946e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Jan 2009 04:14:20 +0100 Subject: s3: always call run_events() before and after sys_select() And always setup the fd events. metze --- source3/smbd/process.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/smbd/process.c') diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 44cacfafdd..7847505f7c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -818,13 +818,11 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * &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)) { - return NT_STATUS_RETRY; - } + /* Process a signal and timed events now... */ + if (run_events(smbd_event_context(), 0, NULL, NULL)) { + return NT_STATUS_RETRY; } - + { int sav; START_PROFILE(smbd_idle); -- cgit From 196028ab7b578526179d4fcff42a5d73ba07ccbb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Jan 2009 14:02:18 +0100 Subject: s3:smbd: restructure kernel oplocks code This converts the irix oplocks code to use a fd event and removes the last special case for file descriptors for the main sys_select(). metze --- source3/smbd/process.c | 44 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) (limited to 'source3/smbd/process.c') diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 7847505f7c..78e66e4620 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -700,13 +700,13 @@ struct idle_event *event_add_idle(struct event_context *event_ctx, notify events etc. ****************************************************************************/ -static void async_processing(fd_set *pfds) +static void async_processing(void) { DEBUG(10,("async_processing: Doing async processing.\n")); process_aio_queue(); - process_kernel_oplocks(smbd_messaging_context(), pfds); + process_kernel_oplocks(smbd_messaging_context()); /* Do the aio check again after receive_local_message as it does a select and may have eaten our signal. */ @@ -726,20 +726,6 @@ static void async_processing(fd_set *pfds) } } -/**************************************************************************** - Add a fd to the set we will be select(2)ing on. -****************************************************************************/ - -static int select_on_fd(int fd, int maxfd, fd_set *fds) -{ - if (fd != -1) { - FD_SET(fd, fds); - maxfd = MAX(maxfd, fd); - } - - return maxfd; -} - /**************************************************************************** Do a select on an two fd's - with timeout. @@ -794,9 +780,9 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * * This is hideously complex - *MUST* be simplified for 3.0 ! JRA. */ - if (oplock_message_waiting(&r_fds)) { + if (oplock_message_waiting()) { DEBUG(10,("receive_message_or_smb: oplock_message is waiting.\n")); - async_processing(&r_fds); + async_processing(); /* * 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 @@ -827,8 +813,6 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * int sav; START_PROFILE(smbd_idle); - maxfd = select_on_fd(oplock_notify_fd(), maxfd, &r_fds); - selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&to); sav = errno; @@ -845,7 +829,7 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * is the best we can do until the oplock code knows more about signals */ if (selrtn == -1 && errno == EINTR) { - async_processing(&r_fds); + async_processing(); /* * 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 @@ -865,22 +849,6 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * return NT_STATUS_RETRY; } - /* - * Ensure we process oplock break messages by preference. - * This is IMPORTANT ! Otherwise we can starve other processes - * sending us an oplock break message. JRA. - */ - - 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 - * indeterminate - we may have done I/O on it in the oplock processing. JRA. - */ - return NT_STATUS_RETRY; - } - /* * We've just woken up from a protentially long select sleep. * Ensure we process local messages as we need to synchronously @@ -935,7 +903,7 @@ void respond_to_all_remaining_local_messages(void) return; } - process_kernel_oplocks(smbd_messaging_context(), NULL); + process_kernel_oplocks(smbd_messaging_context()); return; } -- cgit From 830b31a41aeadf6b688c5f60f114f6137ea13afb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 21 Jan 2009 07:33:19 +0100 Subject: s3:smbd: we don't need to call message_dispatch() anymore it's event triggered now metze --- source3/smbd/process.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'source3/smbd/process.c') diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 78e66e4620..dc038b6b95 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -407,9 +407,6 @@ static void smbd_deferred_open_timer(struct event_context *ev, TALLOC_CTX *mem_ctx = talloc_tos(); uint8_t *inbuf; - /* TODO: remove this hack */ - message_dispatch(smbd_messaging_context()); - inbuf = (uint8_t *)talloc_memdup(mem_ctx, msg->buf.data, msg->buf.length); if (inbuf == NULL) { @@ -757,13 +754,6 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * to.tv_sec = SMBD_SELECT_TIMEOUT; to.tv_usec = 0; - /* - * Note that this call must be before processing any SMB - * messages as we need to synchronously process any messages - * we may have sent to ourselves from the previous SMB. - */ - message_dispatch(smbd_messaging_context()); - /* * Setup the select fd sets. */ @@ -849,16 +839,8 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * return NT_STATUS_RETRY; } - /* - * We've just woken up from a protentially long select sleep. - * Ensure we process local messages as we need to synchronously - * process any messages from other smbd's to avoid file rename race - * conditions. This call is cheap if there are no messages waiting. - * JRA. - */ - message_dispatch(smbd_messaging_context()); - - return NT_STATUS_OK; + /* should not be reached */ + return NT_STATUS_INTERNAL_ERROR; } /* @@ -1874,9 +1856,6 @@ static void smbd_server_connection_read_handler(struct smbd_server_connection *c TALLOC_CTX *mem_ctx = talloc_tos(); NTSTATUS status; - /* TODO: remove this hack */ - message_dispatch(smbd_messaging_context()); - /* TODO: make this completely nonblocking */ status = receive_smb_talloc(mem_ctx, smbd_server_fd(), -- cgit