[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-984-gc192144

Steven Danneman sdanneman at samba.org
Thu Feb 19 02:08:21 GMT 2009


The branch, master has been updated
       via  c19214424b0f8ca0dfa5970880e54807880c443c (commit)
       via  03421944b2bd82caf13946b745e4d634f0559f82 (commit)
       via  c441f58dedc465f59060296815a0bc7f9aeb743f (commit)
      from  cdcd525a05ce851dcb338dfa8c9be3009194aa96 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c19214424b0f8ca0dfa5970880e54807880c443c
Author: todd stecher <todd.stecher at gmail.com>
Date:   Thu Feb 12 13:03:03 2009 -0800

    S3: Log warning in smbstatus about lack of pid in anonymous mode.

commit 03421944b2bd82caf13946b745e4d634f0559f82
Author: todd stecher <todd.stecher at gmail.com>
Date:   Thu Feb 12 00:11:38 2009 -0800

    S3: Stop creating SMBD cores when failing to create a pipe.
    
    This was uncovered when the MAX FD limit was hit, causing an instant core
    and invoking error reporting. This fix causes SMBD to exit, but without
    building a core.

commit c441f58dedc465f59060296815a0bc7f9aeb743f
Author: todd stecher <todd.stecher at gmail.com>
Date:   Tue Feb 17 16:16:35 2009 -0800

    S3: Allow SMBD processes to survive in low memory condidtions
    
    This commit adds a configure argument which allows for setting MADV_PROTECT
    in the madvise() API.  With this enabled the kernel won't kill SMBD when
    it's running low on memory.

-----------------------------------------------------------------------

Summary of changes:
 source3/configure.in        |   28 ++++++++++++++++++++++++++++
 source3/include/includes.h  |    4 ++++
 source3/lib/select.c        |   12 +++++++++++-
 source3/printing/printing.c |   10 +++++++---
 source3/smbd/server.c       |   11 +++++++++++
 source3/utils/status.c      |    4 ++++
 6 files changed, 65 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/configure.in b/source3/configure.in
index 691d0a8..57d475f 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -4718,6 +4718,34 @@ SMB_LIBRARY(lua, 0)
 SMB_LIBRARY(addns, 0, no, [undefined API])
 
 
+#################################################
+# check to see if we should set the protected madvise flag,
+# which will keep smbd alive in low memory conditions
+AC_MSG_CHECKING(whether to protect smbd from being killed in low memory)
+AC_ARG_WITH(madvise-protect,
+[AS_HELP_STRING([--with-madvise-protect], [Include low memory madvise protection (default=no)])],
+[ case "$withval" in
+  yes)
+    AC_TRY_COMPILE([
+        #include <sys/mman.h>
+        ],[
+        int a = MADV_PROTECT;
+        ],
+        [samba_cv_madvise_protect=yes],
+        [samba_cv_madvise_protect=no])
+    if test x"$samba_cv_madvise_protect" = x"yes"; then
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(WITH_MADVISE_PROTECTED,1,[Whether to include low memory protection support])
+    else
+        AC_MSG_ERROR(Low memory protection supporte requires availability of MADVISE_PROTECT flag.)
+    fi
+    ;;
+  *)
+    AC_MSG_RESULT(no)
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
 
 #################################################
 # these tests are taken from the GNU fileutils package
diff --git a/source3/include/includes.h b/source3/include/includes.h
index a9f813b..1906830 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -241,6 +241,10 @@ typedef int ber_int_t;
 #include <aio.h>
 #endif
 
+#ifdef WITH_MADVISE_PROTECTED
+#include <sys/mman.h>
+#endif
+
 /* Special macros that are no-ops except when run under Valgrind on
  * x86.  They've moved a little bit from valgrind 1.0.4 to 1.9.4 */
 #if HAVE_VALGRIND_MEMCHECK_H
diff --git a/source3/lib/select.c b/source3/lib/select.c
index 14e5925..a58530a 100644
--- a/source3/lib/select.c
+++ b/source3/lib/select.c
@@ -59,7 +59,17 @@ int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, s
 
 	if (initialised != sys_getpid()) {
 		if (pipe(select_pipe) == -1)
-			smb_panic("Could not create select pipe");
+		{
+			DEBUG(0, ("sys_select: pipe failed (%s)\n",
+				strerror(errno)));
+			if (readfds != NULL)
+				FD_ZERO(readfds);
+			if (writefds != NULL)
+				FD_ZERO(writefds);
+			if (errorfds != NULL)
+				FD_ZERO(errorfds);
+			return -1;
+		}
 
 		/*
 		 * These next two lines seem to fix a bug with the Linux
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 17ddc55..7179184 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1478,9 +1478,13 @@ void start_background_queue(void)
 
 			ret = sys_select(maxfd, &r_fds, &w_fds, NULL, &to);
 
-			/* If pause_pipe[1] is closed it means the parent smbd
-			 * and children exited or aborted. */
-			if (ret == 1 && FD_ISSET(pause_pipe[1], &r_fds)) {
+			/*
+			 * If pause_pipe[1] is closed it means the parent smbd
+			 * and children exited or aborted. If sys_select()
+			 * failed, then something more sinister is wrong
+			 */
+			if ((ret < 0) ||
+			    (ret == 1 && FD_ISSET(pause_pipe[1], &r_fds))) {
                                 exit_server_cleanly(NULL);
 			}
 
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 075e44d..e8ccba0 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -359,6 +359,10 @@ static void smbd_accept_connection(struct tevent_context *ev,
 		/* Child code ... */
 		am_parent = 0;
 
+#ifdef WITH_MADVISE_PROTECTED
+		madvise(NULL,0,MADV_PROTECT);
+#endif
+
 		/* Stop zombies, the parent explicitly handles
 		 * them, counting worker smbds. */
 		CatchChild();
@@ -690,6 +694,10 @@ static void smbd_parent_loop(struct smbd_parent_context *parent)
 			continue;
 		}
 
+		/* socket error */
+		if (num < 0)
+			exit_server_cleanly("socket error");
+
 		/* 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.
@@ -1127,6 +1135,9 @@ extern void build_options(bool screen);
 	if (is_daemon && !interactive) {
 		DEBUG( 3, ( "Becoming a daemon.\n" ) );
 		become_daemon(Fork, no_process_group);
+#ifdef WITH_MADVISE_PROTECTED
+		madvise(NULL,0,MADV_PROTECT);
+#endif
 	}
 
 #if HAVE_SETPGID
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 590444a..831bdcc 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -409,6 +409,10 @@ static int traverse_sessionid(struct db_record *db, void *state)
 			d_printf("\nSamba version %s\n",samba_version_string());
 			d_printf("PID     Username      Group         Machine                        \n");
 			d_printf("-------------------------------------------------------------------\n");
+			if (lp_security() == SEC_SHARE) {
+				d_printf(" <processes do not show up in "
+				    "anonymous mode>\n");
+			}
 
 			db->traverse_read(db, traverse_sessionid, NULL);
 			TALLOC_FREE(db);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list