svn commit: samba r23502 - in branches/SAMBA_3_0/source/smbd: .
jpeach at samba.org
jpeach at samba.org
Thu Jun 14 18:48:51 GMT 2007
Author: jpeach
Date: 2007-06-14 18:48:51 +0000 (Thu, 14 Jun 2007)
New Revision: 23502
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23502
Log:
Restore exit-on-idle. Small refactoring for clarity. Exit if
we are idle and we timed out waiting for something to do.
Modified:
branches/SAMBA_3_0/source/smbd/server.c
Changeset:
Modified: branches/SAMBA_3_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/server.c 2007-06-14 15:50:47 UTC (rev 23501)
+++ branches/SAMBA_3_0/source/smbd/server.c 2007-06-14 18:48:51 UTC (rev 23502)
@@ -316,6 +316,16 @@
}
/****************************************************************************
+ 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 @@
&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 @@
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));
More information about the samba-cvs
mailing list