[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Fri Aug 12 03:07:02 MDT 2011


The branch, master has been updated
       via  6b3a12b s4-test: use standard process model for 'dc' server
       via  63e5b39 socket-wrapped: added wrappers for dup() and dup2()
      from  b4a730d s3:selftest: run smbtorture3 CHAIN1/CHAIN2 tests

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


- Log -----------------------------------------------------------------
commit 6b3a12b0f4c38c87a1f1ff4227ab78ac7624289d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 12 14:37:04 2011 +1000

    s4-test: use standard process model for 'dc' server
    
    this provides us with both 'standard' and 'single' process models in
    selftest, ensuring that we test the standard process model in the
    build farm
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User: Andrew Tridgell <tridge at samba.org>
    Autobuild-Date: Fri Aug 12 11:06:50 CEST 2011 on sn-devel-104

commit 63e5b395d00535c88274bafb9d5e4b0e9d753b36
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Aug 12 14:28:03 2011 +1000

    socket-wrapped: added wrappers for dup() and dup2()
    
    The Samba4 standard process model uses dup() on incoming sockets as an
    optimisation (it makes select() a tiny bit faster when used).
    
    Adding dup() to socket wrapper allows us to use the standard process
    model in selftest
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 lib/socket_wrapper/socket_wrapper.c |  122 ++++++++++++++++++++++++++++++++++-
 lib/socket_wrapper/socket_wrapper.h |   11 +++
 selftest/target/Samba4.pm           |   32 ++++------
 3 files changed, 143 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 2b52626..9469809 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -127,6 +127,8 @@
 #define real_writev writev
 #define real_socket socket
 #define real_close close
+#define real_dup dup
+#define real_dup2 dup2
 #endif
 
 #ifdef HAVE_GETTIMEOFDAY_TZ
@@ -225,7 +227,6 @@ struct socket_info
 	int connected;
 	int defer_connect;
 
-	char *path;
 	char *tmp_path;
 
 	struct sockaddr *myname;
@@ -2523,7 +2524,6 @@ _PUBLIC_ int swrap_close(int fd)
 		swrap_dump_packet(si, NULL, SWRAP_CLOSE_ACK, NULL, 0);
 	}
 
-	if (si->path) free(si->path);
 	if (si->myname) free(si->myname);
 	if (si->peername) free(si->peername);
 	if (si->tmp_path) {
@@ -2534,3 +2534,121 @@ _PUBLIC_ int swrap_close(int fd)
 
 	return ret;
 }
+
+_PUBLIC_ int swrap_dup(int fd)
+{
+	struct socket_info *si, *si2;
+	int fd2;
+
+	si = find_socket_info(fd);
+
+	if (!si) {
+		return real_dup(fd);
+	}
+
+	if (si->tmp_path) {
+		/* we would need reference counting to handle this */
+		errno = EINVAL;
+		return -1;
+	}
+
+	fd2 = real_dup(fd);
+	if (fd2 == -1) {
+		return -1;
+	}
+
+	si2 = (struct socket_info *)malloc(sizeof(struct socket_info));
+	if (si2 == NULL) {
+		real_close(fd2);
+		errno = ENOMEM;
+		return -1;
+	}
+
+	/* copy the whole structure, then duplicate pointer elements */
+	*si2 = *si;
+
+	si2->fd = fd2;
+
+	if (si2->myname) {
+		si2->myname = sockaddr_dup(si2->myname, si2->myname_len);
+		if (si2->myname == NULL) {
+			real_close(fd2);
+			errno = ENOMEM;
+			return -1;
+		}
+	}
+
+	if (si2->peername) {
+		si2->peername = sockaddr_dup(si2->peername, si2->peername_len);
+		if (si2->peername == NULL) {
+			real_close(fd2);
+			errno = ENOMEM;
+			return -1;
+		}
+	}
+
+	SWRAP_DLIST_ADD(sockets, si2);
+	return fd2;
+}
+
+_PUBLIC_ int swrap_dup2(int fd, int newfd)
+{
+	struct socket_info *si, *si2;
+	int fd2;
+
+	si = find_socket_info(fd);
+
+	if (!si) {
+		return real_dup2(fd, newfd);
+	}
+
+	if (si->tmp_path) {
+		/* we would need reference counting to handle this */
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (find_socket_info(newfd)) {
+		/* dup2() does an implicit close of newfd, which we
+		 * need to emulate */
+		swrap_close(newfd);
+	}
+
+	fd2 = real_dup2(fd, newfd);
+	if (fd2 == -1) {
+		return -1;
+	}
+
+	si2 = (struct socket_info *)malloc(sizeof(struct socket_info));
+	if (si2 == NULL) {
+		real_close(fd2);
+		errno = ENOMEM;
+		return -1;
+	}
+
+	/* copy the whole structure, then duplicate pointer elements */
+	*si2 = *si;
+
+	si2->fd = fd2;
+
+	if (si2->myname) {
+		si2->myname = sockaddr_dup(si2->myname, si2->myname_len);
+		if (si2->myname == NULL) {
+			real_close(fd2);
+			errno = ENOMEM;
+			return -1;
+		}
+	}
+
+	if (si2->peername) {
+		si2->peername = sockaddr_dup(si2->peername, si2->peername_len);
+		if (si2->peername == NULL) {
+			real_close(fd2);
+			errno = ENOMEM;
+			return -1;
+		}
+	}
+
+	SWRAP_DLIST_ADD(sockets, si2);
+	return fd2;
+}
diff --git a/lib/socket_wrapper/socket_wrapper.h b/lib/socket_wrapper/socket_wrapper.h
index 77af6fe..32c9de6 100644
--- a/lib/socket_wrapper/socket_wrapper.h
+++ b/lib/socket_wrapper/socket_wrapper.h
@@ -58,6 +58,8 @@ ssize_t swrap_send(int s, const void *buf, size_t len, int flags);
 int swrap_readv(int s, const struct iovec *vector, size_t count);
 int swrap_writev(int s, const struct iovec *vector, size_t count);
 int swrap_close(int);
+int swrap_dup(int oldfd);
+int swrap_dup2(int oldfd, int newfd);
 
 #ifdef SOCKET_WRAPPER_REPLACE
 
@@ -160,7 +162,16 @@ int swrap_close(int);
 #undef close
 #endif
 #define close(s)			swrap_close(s)
+
+#ifdef dup
+#undef dup
 #endif
+#define dup(s)			swrap_dup(s)
 
+#ifdef dup2
+#undef dup2
+#endif
+#define dup2(s, s2)		swrap_dup2(s, s2)
 
+#endif /* SOCKET_WRAPPER_REPLACE */
 #endif /* __SOCKET_WRAPPER_H__ */
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 825c40c..89faf01 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -85,9 +85,9 @@ sub slapd_stop($$)
 	return 1;
 }
 
-sub check_or_start($$)
+sub check_or_start($$$)
 {
-	my ($self, $env_vars) = @_;
+	my ($self, $env_vars, $process_model) = @_;
 	return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
 
 	unlink($env_vars->{SAMBA_TEST_FIFO});
@@ -135,16 +135,8 @@ sub check_or_start($$)
 		}
 		my $samba =  Samba::bindir_path($self, "samba");
 
-		# allow selection of the process model using
-		# the environment varibale SAMBA_PROCESS_MODEL
-		# that allows us to change the process model for
-		# individual machines in the build farm
-		my $model = "single";
-		if (defined($ENV{SAMBA_PROCESS_MODEL})) {
-			$model = $ENV{SAMBA_PROCESS_MODEL};
-		}
 		chomp($pwd);
-		my $cmdline = "$valgrind ${pwd}/$samba $optarg $env_vars->{CONFIGURATION} -M $model -i";
+		my $cmdline = "$valgrind ${pwd}/$samba $optarg $env_vars->{CONFIGURATION} -M $process_model -i";
 		my $ret = system("$cmdline");
 		if ($ret == -1) {
 			print "Unable to start $cmdline: $ret: $!\n";
@@ -1423,7 +1415,7 @@ sub setup_member($$$)
 	my $env = $self->provision_member($path, $dc_vars);
 
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1440,7 +1432,7 @@ sub setup_rpc_proxy($$$)
 	my $env = $self->provision_rpc_proxy($path, $dc_vars);
 
 	if (defined $env) {
-	        $self->check_or_start($env);
+	        $self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1455,7 +1447,7 @@ sub setup_dc($$)
 
 	my $env = $self->provision_dc($path);
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "standard");
 
 		$self->wait_for_start($env);
 
@@ -1470,7 +1462,7 @@ sub setup_fl2000dc($$)
 
 	my $env = $self->provision_fl2000dc($path);
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1487,7 +1479,7 @@ sub setup_fl2003dc($$)
 	my $env = $self->provision_fl2003dc($path);
 
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1503,7 +1495,7 @@ sub setup_fl2008r2dc($$)
 	my $env = $self->provision_fl2008r2dc($path);
 
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1520,7 +1512,7 @@ sub setup_vampire_dc($$$)
 	my $env = $self->provision_vampire_dc($path, $dc_vars);
 
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 
@@ -1573,7 +1565,7 @@ sub setup_rodc($$$)
 		return undef;
 	}
 
-	$self->check_or_start($env);
+	$self->check_or_start($env, "single");
 
 	$self->wait_for_start($env);
 
@@ -1588,7 +1580,7 @@ sub setup_plugin_s4_dc($$)
 
 	my $env = $self->provision_plugin_s4_dc($path);
 	if (defined $env) {
-		$self->check_or_start($env);
+		$self->check_or_start($env, "single");
 
 		$self->wait_for_start($env);
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list