Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Dec 2010 11:03:00 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r216354 - stable/8/tools/regression/sockets/unix_gc
Message-ID:  <201012101103.oBAB30g9071710@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Dec 10 11:02:59 2010
New Revision: 216354
URL: http://svn.freebsd.org/changeset/base/216354

Log:
  MFC r216151:
  Extend the unix gc regression test to cover the case of r216150.
  
  Approved by:    re (bz)

Modified:
  stable/8/tools/regression/sockets/unix_gc/unix_gc.c
Directory Properties:
  stable/8/tools/regression/sockets/unix_gc/   (props changed)

Modified: stable/8/tools/regression/sockets/unix_gc/unix_gc.c
==============================================================================
--- stable/8/tools/regression/sockets/unix_gc/unix_gc.c	Fri Dec 10 10:48:54 2010	(r216353)
+++ stable/8/tools/regression/sockets/unix_gc/unix_gc.c	Fri Dec 10 11:02:59 2010	(r216354)
@@ -55,27 +55,36 @@ static char dpath[PATH_MAX];
 static const char *test;
 
 static int
-getopenfiles(void)
+getsysctl(const char *name)
 {
 	size_t len;
 	int i;
 
 	len = sizeof(i);
-	if (sysctlbyname("kern.openfiles", &i, &len, NULL, 0) < 0)
-		err(-1, "kern.openfiles");
+	if (sysctlbyname(name, &i, &len, NULL, 0) < 0)
+		err(-1, "%s", name);
 	return (i);
 }
 
 static int
+getopenfiles(void)
+{
+
+	return (getsysctl("kern.openfiles"));
+}
+
+static int
 getinflight(void)
 {
-	size_t len;
-	int i;
 
-	len = sizeof(i);
-	if (sysctlbyname("net.local.inflight", &i, &len, NULL, 0) < 0)
-		err(-1, "net.local.inflight");
-	return (i);
+	return (getsysctl("net.local.inflight"));
+}
+
+static int
+getdeferred(void)
+{
+
+	return (getsysctl("net.local.deferred"));
 }
 
 static void
@@ -707,6 +716,40 @@ listen_connect_drop(void)
 	test_sysctls(inflight, openfiles);
 }
 
+static void
+recursion(void)
+{
+	int fd[2], ff[2];
+	int inflight, openfiles, deferred, deferred1;
+
+	test = "recursion";
+	printf("%s\n", test);
+	save_sysctls(&inflight, &openfiles);
+	deferred = getdeferred();
+
+	my_socketpair(fd);
+
+	for (;;) {
+		if (socketpair(PF_UNIX, SOCK_STREAM, 0, ff) == -1) {
+			if (errno == EMFILE || errno == ENFILE)
+				break;
+			err(-1, "socketpair");
+		}
+		sendfd(ff[0], fd[0]);
+		sendfd(ff[0], fd[1]);
+		close2(fd[1], fd[0]);
+		fd[0] = ff[0];
+		fd[1] = ff[1];
+	}
+	close2(fd[0], fd[1]);
+	sleep(1);
+	test_sysctls(inflight, openfiles);
+	deferred1 = getdeferred();
+	if (deferred != deferred1)
+		errx(-1, "recursion: deferred before %d after %d", deferred,
+		    deferred1);
+}
+
 #define	RMDIR	"rm -Rf "
 int
 main(int argc, char *argv[])
@@ -757,6 +800,8 @@ main(int argc, char *argv[])
 	listen_connect_nothing();
 	listen_connect_drop();
 
+	recursion();
+
 	printf("Finish: inflight %d open %d\n", getinflight(),
 	    getopenfiles());
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012101103.oBAB30g9071710>