From ca62bc5f7eba17554e72b48f2a84137f338a272d Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sat, 23 Jan 2016 22:51:22 +0000 Subject: [PATCH] Use different ports in the TCP/UDP testcases with the first set and the second set (increment the original ports by 10) This avoids issues where the first listening socket might not be torn down by the time it makes it to the second set of testcases. The sockets should likely only be setup once, but this keeps in the spirit of the original testcases, so this will be easier to backport to ^/stable/9 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- tools/regression/sockets/zerosend/zerosend.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/regression/sockets/zerosend/zerosend.c b/tools/regression/sockets/zerosend/zerosend.c index 5d29c0cd5b5e..ac9542a93617 100644 --- a/tools/regression/sockets/zerosend/zerosend.c +++ b/tools/regression/sockets/zerosend/zerosend.c @@ -74,7 +74,7 @@ try_0write(const char *test, int fd) } static void -setup_udp(const char *test, int *fdp) +setup_udp(const char *test, int *fdp, int port1, int port2) { struct sockaddr_in sin; int sock1, sock2; @@ -84,14 +84,14 @@ setup_udp(const char *test, int *fdp) sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - sin.sin_port = htons(PORT1); + sin.sin_port = htons(port1); sock1 = socket(PF_INET, SOCK_DGRAM, 0); if (sock1 < 0) err(1, "%s: setup_udp: socket", test); if (bind(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0) err(1, "%s: setup_udp: bind(%s, %d)", test, inet_ntoa(sin.sin_addr), PORT1); - sin.sin_port = htons(PORT2); + sin.sin_port = htons(port2); if (connect(sock1, (struct sockaddr *)&sin, sizeof(sin)) < 0) err(1, "%s: setup_udp: connect(%s, %d)", test, inet_ntoa(sin.sin_addr), PORT2); @@ -102,7 +102,7 @@ setup_udp(const char *test, int *fdp) if (bind(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0) err(1, "%s: setup_udp: bind(%s, %d)", test, inet_ntoa(sin.sin_addr), PORT2); - sin.sin_port = htons(PORT1); + sin.sin_port = htons(port1); if (connect(sock2, (struct sockaddr *)&sin, sizeof(sin)) < 0) err(1, "%s: setup_udp: connect(%s, %d)", test, inet_ntoa(sin.sin_addr), PORT1); @@ -112,7 +112,7 @@ setup_udp(const char *test, int *fdp) } static void -setup_tcp(const char *test, int *fdp) +setup_tcp(const char *test, int *fdp, int port) { fd_set writefds, exceptfds; struct sockaddr_in sin; @@ -127,7 +127,7 @@ setup_tcp(const char *test, int *fdp) /* * First set up the listen socket. */ - sin.sin_port = htons(PORT1); + sin.sin_port = htons(port); sock1 = socket(PF_INET, SOCK_STREAM, 0); if (sock1 < 0) err(1, "%s: setup_tcp: socket", test); @@ -246,19 +246,19 @@ main(void) { int fd[2]; - setup_udp("udp_0send", fd); + setup_udp("udp_0send", fd, PORT1, PORT2); try_0send("udp_0send", fd[0]); close_both(fd); - setup_udp("udp_0write", fd); + setup_udp("udp_0write", fd, PORT1 + 10, PORT2 + 10); try_0write("udp_0write", fd[0]); close_both(fd); - setup_tcp("tcp_0send", fd); + setup_tcp("tcp_0send", fd, PORT1); try_0send("tcp_0send", fd[0]); close_both(fd); - setup_tcp("tcp_0write", fd); + setup_tcp("tcp_0write", fd, PORT1 + 10); try_0write("tcp_0write", fd[0]); close_both(fd);