summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2007-06-14 18:48:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:22 -0500
commit4a3e4db1cde61f41e5700ad696645f2910c2cbb9 (patch)
tree6995b4fe35c53fd691a3b94bd3073278eb002b3f /source3/smbd
parent59c872103dc82a1a9dcb743b39e4ca0f0205dad2 (diff)
downloadsamba-4a3e4db1cde61f41e5700ad696645f2910c2cbb9.tar.gz
samba-4a3e4db1cde61f41e5700ad696645f2910c2cbb9.tar.bz2
samba-4a3e4db1cde61f41e5700ad696645f2910c2cbb9.zip
r23502: Restore exit-on-idle. Small refactoring for clarity. Exit if
we are idle and we timed out waiting for something to do. (This used to be commit b4ab1a0cd992cf9e966b8edb9796d1eae53db744)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/server.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 98b9fb8626..532de36bf8 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -316,6 +316,16 @@ static BOOL allowable_number_of_smbd_processes(void)
}
/****************************************************************************
+ Are we idle enough that we could safely exit?
+****************************************************************************/
+
+static BOOL smbd_is_idle(void)
+{
+ /* Currently we define "idle" as having no client connections. */
+ return count_all_current_connections() == 0;
+}
+
+/****************************************************************************
Open the socket communication.
****************************************************************************/
@@ -414,10 +424,22 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
&r_fds, &w_fds, &idle_timeout,
&maxfd);
- num = sys_select(maxfd+1,&r_fds,&w_fds,NULL,
- timeval_is_zero(&idle_timeout) ?
- NULL : &idle_timeout);
-
+ if (timeval_is_zero(&idle_timeout)) {
+ num = sys_select(maxfd + 1, &r_fds, &w_fds,
+ NULL, NULL);
+ } else {
+ num = sys_select(maxfd + 1, &r_fds, &w_fds,
+ NULL, &idle_timeout);
+
+ /* If the idle timeout fired and we are idle, exit
+ * gracefully. We expect to be running under a process
+ * controller that will restart us if necessry.
+ */
+ if (num == 0 && smbd_is_idle()) {
+ exit_server_cleanly("idle timeout");
+ }
+ }
+
if (num == -1 && errno == EINTR) {
if (got_sig_term) {
exit_server_cleanly(NULL);
@@ -438,19 +460,6 @@ static BOOL open_sockets_smbd(enum smb_server_mode server_mode, const char *smb_
continue;
}
-#if 0
- Deactivated for now, this needs to become a timed event
- vl
-
- /* If the idle timeout fired and we don't have any connected
- * users, exit gracefully. We should be running under a process
- * controller that will restart us if necessry.
- */
- if (num == 0 && count_all_current_connections() == 0) {
- exit_server_cleanly("idle timeout");
- }
-#endif
-
/* check if we need to reload services */
check_reload(time(NULL));