Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F105583205
D35122.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D35122.diff
View Options
diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c
--- a/tests/sys/kern/unix_passfd_test.c
+++ b/tests/sys/kern/unix_passfd_test.c
@@ -118,6 +118,17 @@
return (n);
}
+static int
+openfiles(void)
+{
+ int files;
+ size_t len = sizeof(files);
+
+ ATF_REQUIRE(sysctlbyname("kern.openfiles", &files, &len, NULL, 0) == 0);
+
+ return (files);
+}
+
static void
putfds(char *buf, int fd, int nfds)
{
@@ -336,6 +347,28 @@
closesocketpair(fd);
}
+/*
+ * Send file then shutdown receive side to exercise unp_dispose() call
+ * via soshutdown(). Check that shutdown(SHUT_RD) would gc the file
+ * reference sitting in the receive buffer. There is no good way of
+ * checking that except using global open file count.
+ */
+ATF_TC_WITHOUT_HEAD(send_and_shutdown);
+ATF_TC_BODY(send_and_shutdown, tc)
+{
+ int fd[2], putfd, nfiles;
+
+ domainsocketpair(fd);
+ tempfile(&putfd);
+ sendfd(fd[0], putfd);
+ nfiles = openfiles();
+ close(putfd);
+ ATF_REQUIRE(openfiles() == nfiles);
+ shutdown(fd[1], SHUT_RD);
+ ATF_REQUIRE(openfiles() == nfiles - 1);
+ closesocketpair(fd);
+}
+
/*
* Send two files. Then receive them. Make sure they are returned in the
* right order, and both get there.
@@ -722,6 +755,7 @@
ATF_TP_ADD_TC(tp, simple_send_fd_msg_cmsg_cloexec);
ATF_TP_ADD_TC(tp, send_and_close);
ATF_TP_ADD_TC(tp, send_and_cancel);
+ ATF_TP_ADD_TC(tp, send_and_shutdown);
ATF_TP_ADD_TC(tp, two_files);
ATF_TP_ADD_TC(tp, bundle);
ATF_TP_ADD_TC(tp, bundle_cancel);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 10:55 PM (20 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15496751
Default Alt Text
D35122.diff (1 KB)
Attached To
Mode
D35122: tests/unix_passfd: add test for shutdown(2) on a buffer with an fd
Attached
Detach File
Event Timeline
Log In to Comment