Date: Thu, 27 May 2010 15:28:55 +0000 (UTC) From: Robert Watson <rwatson@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r208602 - head/tools/regression/sockets/unix_close_race Message-ID: <201005271528.o4RFStEc011259@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rwatson Date: Thu May 27 15:28:55 2010 New Revision: 208602 URL: http://svn.freebsd.org/changeset/base/208602 Log: Correct several nits/problems in the unix_close_race regression test. Submitted by: Mikolaj Golub <to.my.trociny at gmail.com> MFC after: 3 days Modified: head/tools/regression/sockets/unix_close_race/unix_close_race.c Modified: head/tools/regression/sockets/unix_close_race/unix_close_race.c ============================================================================== --- head/tools/regression/sockets/unix_close_race/unix_close_race.c Thu May 27 15:27:31 2010 (r208601) +++ head/tools/regression/sockets/unix_close_race/unix_close_race.c Thu May 27 15:28:55 2010 (r208602) @@ -75,8 +75,8 @@ main(int argc, char **argv) warnx("SMP not present, test may be unable to trigger race"); /* - * Create a UNIX domain socket that the parent will repeatedly - * accept() from, and that the child will repeatedly connect() to. + * Create a UNIX domain socket that the child will repeatedly + * accept() from, and that the parent will repeatedly connect() to. */ if ((listenfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) err(1, "parent: socket error"); @@ -104,13 +104,19 @@ main(int argc, char **argv) servaddr.sun_family = AF_LOCAL; strcpy(servaddr.sun_path, UNIXSTR_PATH); for (counter = 0; counter < LOOPS; counter++) { - if ((connfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) - err(1, "child: socket error"); + if ((connfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) { + (void)kill(pid, SIGTERM); + err(1, "parent: socket error"); + } if (connect(connfd, (struct sockaddr *)&servaddr, - sizeof(servaddr)) < 0) - err(1, "child: connect error"); - if (close(connfd) < 0) - err(1, "child: close error"); + sizeof(servaddr)) < 0) { + (void)kill(pid, SIGTERM); + err(1, "parent: connect error"); + } + if (close(connfd) < 0) { + (void)kill(pid, SIGTERM); + err(1, "parent: close error"); + } usleep(USLEEP); } (void)kill(pid, SIGTERM); @@ -122,9 +128,9 @@ main(int argc, char **argv) for ( ; ; ) { if ((connfd = accept(listenfd, (struct sockaddr *)NULL, NULL)) < 0) - err(1, "parent: accept error"); + err(1, "child: accept error"); if (close(connfd) < 0) - err(1, "parent: close error"); + err(1, "child: close error"); } } printf("OK\n");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005271528.o4RFStEc011259>