diff options
author | Jeremy Allison <jra@samba.org> | 2006-04-14 03:55:42 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2006-04-14 03:55:42 +0000 |
commit | 56ceeaa27e0ebc50c071f715db2e20863757c7e3 (patch) | |
tree | cf21fbda8fd51e32018dfca607a8b5620babc251 | |
parent | bdb16ea77808ebca1ff1543c4e857b1fd99ad8b5 (diff) | |
download | samba-56ceeaa27e0ebc50c071f715db2e20863757c7e3.tar.gz samba-56ceeaa27e0ebc50c071f715db2e20863757c7e3.tar.xz samba-56ceeaa27e0ebc50c071f715db2e20863757c7e3.zip |
r15084: Try and squeeze more out of the non-read/write code path.
Jeremy.
-rw-r--r-- | source/lib/events.c | 8 | ||||
-rw-r--r-- | source/nsswitch/winbindd_dual.c | 5 | ||||
-rw-r--r-- | source/smbd/process.c | 15 |
3 files changed, 17 insertions, 11 deletions
diff --git a/source/lib/events.c b/source/lib/events.c index 133752c78e4..242c198511e 100644 --- a/source/lib/events.c +++ b/source/lib/events.c @@ -103,16 +103,12 @@ void run_events(void) return; } -struct timeval *get_timed_events_timeout(struct timeval *to_ret, time_t default_to) +struct timeval *get_timed_events_timeout(struct timeval *to_ret) { struct timeval now; if (timed_events == NULL) { - if (default_to == (time_t)-1) { - return NULL; - } - *to_ret = timeval_set(default_to, 0); - return to_ret; + return NULL; } now = timeval_current(); diff --git a/source/nsswitch/winbindd_dual.c b/source/nsswitch/winbindd_dual.c index d978a6adf79..c5d24f98c1b 100644 --- a/source/nsswitch/winbindd_dual.c +++ b/source/nsswitch/winbindd_dual.c @@ -684,9 +684,10 @@ static BOOL fork_domain_child(struct winbindd_child *child) GetTimeOfDay(&now); - tp = get_timed_events_timeout(&t, (time_t)-1); + tp = get_timed_events_timeout(&t); if (tp) { - DEBUG(11,("select will use timeout of %d seconds\n", (int)tp->tv_sec)); + DEBUG(11,("select will use timeout of %u.%u seconds\n", + (unsigned int)tp->tv_sec, (unsigned int)tp->tv_usec )); } /* Handle messages */ diff --git a/source/smbd/process.c b/source/smbd/process.c index c0a43e99dd3..ba14e57c54a 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -357,7 +357,7 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) { fd_set fds; int selrtn; - struct timeval to = timeval_set(SMBD_SELECT_TIMEOUT, 0); + struct timeval to; int maxfd = 0; smb_read_error = 0; @@ -367,6 +367,9 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) if (timeout >= 0) { to.tv_sec = timeout / 1000; to.tv_usec = (timeout % 1000) * 1000; + } else { + to.tv_sec = SMBD_SELECT_TIMEOUT; + to.tv_usec = 0; } /* @@ -441,14 +444,20 @@ static BOOL receive_message_or_smb(char *buffer, int buffer_len, int timeout) goto again; } + /* + * Are there any timed events waiting ? If so, ensure we don't + * select for longer than it would take to wait for them. + */ + { struct timeval tmp; - struct timeval *tp = get_timed_events_timeout(&tmp,SMBD_SELECT_TIMEOUT); + struct timeval *tp = get_timed_events_timeout(&tmp); if (tp) { to = timeval_min(&to, tp); if (timeval_is_zero(&to)) { - return True; + /* Process a timed event now... */ + run_events(); } } } |