summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-01-20 04:14:20 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-22 12:37:29 +0100
commit048f8dba141c2f9898aad67e09925f03394a946e (patch)
treed975868b616cfc80d12df0979d21fb08a255c089 /source3
parentf9dcd3d2b79e4c1e19ac1c81e3e75370c8716586 (diff)
downloadsamba-048f8dba141c2f9898aad67e09925f03394a946e.tar.gz
samba-048f8dba141c2f9898aad67e09925f03394a946e.tar.bz2
samba-048f8dba141c2f9898aad67e09925f03394a946e.zip
s3: always call run_events() before and after sys_select()
And always setup the fd events. metze
Diffstat (limited to 'source3')
-rw-r--r--source3/nmbd/nmbd_packets.c16
-rw-r--r--source3/smbd/process.c10
-rw-r--r--source3/smbd/server.c12
-rw-r--r--source3/winbindd/winbindd.c2
-rw-r--r--source3/winbindd/winbindd_dual.c33
5 files changed, 45 insertions, 28 deletions
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 66b584ad54..489034899e 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1773,6 +1773,11 @@ bool listen_for_packets(bool run_election)
}
#endif
+ /* Process a signal and timer events now... */
+ if (run_events(nmbd_event_context(), 0, NULL, NULL)) {
+ return False;
+ }
+
/*
* During elections and when expecting a netbios response packet we
* need to send election packets at tighter intervals.
@@ -1789,13 +1794,6 @@ bool listen_for_packets(bool run_election)
&r_fds, &w_fds, &timeout, &maxfd);
}
- if (timeval_is_zero(&timeout)) {
- /* Process a timed event now... */
- if (run_events(nmbd_event_context(), 0, NULL, NULL)) {
- return False;
- }
- }
-
/* Prepare for the select - allow certain signals. */
BlockSignals(False, SIGTERM);
@@ -1806,11 +1804,11 @@ bool listen_for_packets(bool run_election)
BlockSignals(True, SIGTERM);
- if(selrtn == -1) {
+ if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) {
return False;
}
- if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) {
+ if (selrtn == -1) {
return False;
}
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);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 42c37f2056..163d0b81be 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -602,6 +602,10 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
}
}
+ if (run_events(smbd_event_context(), 0, NULL, NULL)) {
+ continue;
+ }
+
idle_timeout = timeval_zero();
memcpy((char *)&r_fds, (char *)&listen_set,
@@ -623,6 +627,10 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
timeval_is_zero(&idle_timeout) ?
NULL : &idle_timeout);
+ if (run_events(smbd_event_context(), num, &r_fds, &w_fds)) {
+ continue;
+ }
+
if (num == -1 && errno == EINTR) {
if (got_sig_term) {
exit_server_cleanly(NULL);
@@ -653,10 +661,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
--num;
}
- if (run_events(smbd_event_context(), num, &r_fds, &w_fds)) {
- continue;
- }
-
/* check if we need to reload services */
check_reload(time(NULL));
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 821812925c..0bdc75ccd4 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -980,6 +980,8 @@ static void process_loop(void)
no_fds_ready:
+ run_events(winbind_event_context(), selret, &r_fds, &w_fds);
+
#if 0
winbindd_check_cache_size(time(NULL));
#endif
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 4b57d08b03..2a85f6e0d4 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1371,7 +1371,9 @@ static bool fork_domain_child(struct winbindd_child *child)
while (1) {
int ret;
- fd_set read_fds;
+ fd_set r_fds;
+ fd_set w_fds;
+ int maxfd;
struct timeval t;
struct timeval *tp;
struct timeval now;
@@ -1382,7 +1384,14 @@ static bool fork_domain_child(struct winbindd_child *child)
winbind_check_sighup(override_logfile ? NULL :
child->logfilename);
- run_events(winbind_event_context(), 0, NULL, NULL);
+ /* Handle messages */
+
+ message_dispatch(winbind_messaging_context());
+
+ if (run_events(winbind_event_context(), 0, NULL, NULL)) {
+ TALLOC_FREE(frame);
+ continue;
+ }
GetTimeOfDay(&now);
@@ -1394,20 +1403,26 @@ static bool fork_domain_child(struct winbindd_child *child)
child->domain->startup = False;
}
+ FD_ZERO(&r_fds);
+ FD_ZERO(&w_fds);
+ FD_SET(state.sock, &r_fds);
+ maxfd = state.sock;
+
+ event_add_to_select_args(winbind_event_context(), &now,
+ &r_fds, &w_fds, &t, &maxfd);
tp = get_timed_events_timeout(winbind_event_context(), &t);
if (tp) {
DEBUG(11,("select will use timeout of %u.%u seconds\n",
(unsigned int)tp->tv_sec, (unsigned int)tp->tv_usec ));
}
- /* Handle messages */
-
- message_dispatch(winbind_messaging_context());
-
- FD_ZERO(&read_fds);
- FD_SET(state.sock, &read_fds);
+ ret = sys_select(maxfd + 1, &r_fds, &w_fds, NULL, tp);
- ret = sys_select(state.sock + 1, &read_fds, NULL, NULL, tp);
+ if (run_events(winbind_event_context(), ret, &r_fds, &w_fds)) {
+ /* We got a signal - continue. */
+ TALLOC_FREE(frame);
+ continue;
+ }
if (ret == 0) {
DEBUG(11,("nothing is ready yet, continue\n"));