summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/event.h2
-rw-r--r--source3/lib/events.c22
-rw-r--r--source3/nmbd/nmbd_packets.c6
-rw-r--r--source3/smbd/process.c39
-rw-r--r--source3/winbindd/winbindd_dual.c6
5 files changed, 35 insertions, 40 deletions
diff --git a/source3/include/event.h b/source3/include/event.h
index 101a967c47..dc45b76896 100644
--- a/source3/include/event.h
+++ b/source3/include/event.h
@@ -30,7 +30,7 @@ bool event_add_to_select_args(struct event_context *event_ctx,
fd_set *read_fds, fd_set *write_fds,
struct timeval *timeout, int *maxfd);
bool run_events(struct event_context *event_ctx,
- int *selrtn, fd_set *read_fds, fd_set *write_fds);
+ int selrtn, fd_set *read_fds, fd_set *write_fds);
struct timeval *get_timed_events_timeout(struct event_context *event_ctx,
struct timeval *to_ret);
void dump_event_list(struct event_context *event_ctx);
diff --git a/source3/lib/events.c b/source3/lib/events.c
index d987072884..7670eb1f10 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -68,7 +68,7 @@ bool event_add_to_select_args(struct tevent_context *ev,
}
bool run_events(struct tevent_context *ev,
- int *selrtn, fd_set *read_fds, fd_set *write_fds)
+ int selrtn, fd_set *read_fds, fd_set *write_fds)
{
struct tevent_fd *fde;
struct timeval now;
@@ -113,7 +113,7 @@ bool run_events(struct tevent_context *ev,
return true;
}
- if (*selrtn <= 0) {
+ if (selrtn == 0) {
/*
* No fd ready
*/
@@ -123,16 +123,8 @@ bool run_events(struct tevent_context *ev,
for (fde = ev->fd_events; fde; fde = fde->next) {
uint16 flags = 0;
- if (FD_ISSET(fde->fd, read_fds)) {
- flags |= EVENT_FD_READ;
- FD_CLR(fde->fd, read_fds);
- (*selrtn)--;
- }
- if (FD_ISSET(fde->fd, write_fds)) {
- flags |= EVENT_FD_WRITE;
- FD_CLR(fde->fd, write_fds);
- (*selrtn)--;
- }
+ if (FD_ISSET(fde->fd, read_fds)) flags |= EVENT_FD_READ;
+ if (FD_ISSET(fde->fd, write_fds)) flags |= EVENT_FD_WRITE;
if (flags & fde->flags) {
fde->handler(ev, fde, flags, fde->private_data);
@@ -171,7 +163,7 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location)
struct timeval to;
fd_set r_fds, w_fds;
int maxfd = 0;
- int ret = 0;
+ int ret;
FD_ZERO(&r_fds);
FD_ZERO(&w_fds);
@@ -179,7 +171,7 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location)
to.tv_sec = 9999; /* Max timeout */
to.tv_usec = 0;
- if (run_events(ev, &ret, NULL, NULL)) {
+ if (run_events(ev, 0, NULL, NULL)) {
return 0;
}
@@ -196,7 +188,7 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location)
return -1;
}
- run_events(ev, &ret, &r_fds, &w_fds);
+ run_events(ev, ret, &r_fds, &w_fds);
return 0;
}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 73ee141104..48d10cc26d 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1857,7 +1857,7 @@ bool listen_for_packets(bool run_election)
fd_set r_fds;
fd_set w_fds;
- int selrtn = 0;
+ int selrtn;
struct timeval timeout;
#ifndef SYNC_DNS
int dns_fd;
@@ -1884,7 +1884,7 @@ bool listen_for_packets(bool run_election)
#endif
/* Process a signal and timer events now... */
- if (run_events(nmbd_event_context(), &selrtn, NULL, NULL)) {
+ if (run_events(nmbd_event_context(), 0, NULL, NULL)) {
return False;
}
@@ -1903,7 +1903,7 @@ bool listen_for_packets(bool run_election)
selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&timeout);
- if (run_events(nmbd_event_context(), &selrtn, &r_fds, &w_fds)) {
+ if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) {
return False;
}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 12ea28a399..04ea747564 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -963,7 +963,7 @@ void smbd_setup_sig_hup_handler(struct tevent_context *ev,
static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn)
{
fd_set r_fds, w_fds;
- int selrtn = 0;
+ int selrtn;
struct timeval to;
int maxfd = 0;
@@ -986,7 +986,7 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *
&r_fds, &w_fds, &to, &maxfd);
/* Process a signal and timed events now... */
- if (run_events(smbd_event_context(), &selrtn, NULL, NULL)) {
+ if (run_events(smbd_event_context(), 0, NULL, NULL)) {
return NT_STATUS_RETRY;
}
@@ -1003,23 +1003,26 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *
/* Check if error */
if (selrtn == -1) {
- if (errno == EINTR)
- return NT_STATUS_RETRY;
- else
- /* Maybe the socket is dead? */
- return map_nt_error_from_unix(errno);
- }
-
- /* Process events until all available fds have been handled.
- * This allows for fair round-robin handling of all available fds
- * on each select() wakeup, while still maintaining responsiveness
- * by re-checking for signal and timed events between the handling
- * of each ready fd. */
- do {
- run_events(smbd_event_context(), &selrtn, &r_fds, &w_fds);
- } while (selrtn > 0);
+ /* something is wrong. Maybe the socket is dead? */
+ return map_nt_error_from_unix(errno);
+ }
+
+ if ((conn->smb1.echo_handler.trusted_fd != -1)
+ && FD_ISSET(conn->sock, &r_fds)
+ && FD_ISSET(conn->smb1.echo_handler.trusted_fd, &r_fds)) {
+ /*
+ * Prefer to read pending requests from the echo handler. To
+ * quote Jeremy (da70f8ab1): This is a hack of monstrous
+ * proportions...
+ */
+ FD_CLR(conn->sock, &r_fds);
+ }
+
+ if (run_events(smbd_event_context(), selrtn, &r_fds, &w_fds)) {
+ return NT_STATUS_RETRY;
+ }
- /* Processed all fds or timed out */
+ /* Did we timeout ? */
if (selrtn == 0) {
return NT_STATUS_RETRY;
}
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index a32459d595..ac50a5637a 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1418,7 +1418,7 @@ static bool fork_domain_child(struct winbindd_child *child)
while (1) {
- int ret = 0;
+ int ret;
fd_set r_fds;
fd_set w_fds;
int maxfd;
@@ -1429,7 +1429,7 @@ static bool fork_domain_child(struct winbindd_child *child)
int iov_count;
NTSTATUS status;
- if (run_events(winbind_event_context(), &ret, NULL, NULL)) {
+ if (run_events(winbind_event_context(), 0, NULL, NULL)) {
TALLOC_FREE(frame);
continue;
}
@@ -1465,7 +1465,7 @@ static bool fork_domain_child(struct winbindd_child *child)
ret = sys_select(maxfd + 1, &r_fds, &w_fds, NULL, tp);
- if (run_events(winbind_event_context(), &ret, &r_fds, &w_fds)) {
+ if (run_events(winbind_event_context(), ret, &r_fds, &w_fds)) {
/* We got a signal - continue. */
TALLOC_FREE(frame);
continue;