diff options
author | ngie <ngie@FreeBSD.org> | 2015-04-11 03:43:43 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2015-04-11 03:43:43 +0000 |
commit | 1d4bda01f8fabc16c9a6310129567a3ee517626f (patch) | |
tree | 7674df20783fd85a6bdc3971f79d72dc1090b173 /tools | |
parent | 1add384e4dd97e57ad8135216729c7d3407c51b6 (diff) | |
download | FreeBSD-src-1d4bda01f8fabc16c9a6310129567a3ee517626f.zip FreeBSD-src-1d4bda01f8fabc16c9a6310129567a3ee517626f.tar.gz |
- Garbage collect argc/argv; bump WARNS to 6
- Make the socket path random and move it out of /tmp as that's outside ATF's
prescribed path
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/sockets/unix_close_race/Makefile | 2 | ||||
-rw-r--r-- | tools/regression/sockets/unix_close_race/unix_close_race.c | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/tools/regression/sockets/unix_close_race/Makefile b/tools/regression/sockets/unix_close_race/Makefile index 8b9f792..370adc4 100644 --- a/tools/regression/sockets/unix_close_race/Makefile +++ b/tools/regression/sockets/unix_close_race/Makefile @@ -2,6 +2,6 @@ PROG= unix_close_race MAN= -WARNS?= 3 +WARNS?= 6 .include <bsd.prog.mk> diff --git a/tools/regression/sockets/unix_close_race/unix_close_race.c b/tools/regression/sockets/unix_close_race/unix_close_race.c index 97783e3..89c1b20 100644 --- a/tools/regression/sockets/unix_close_race/unix_close_race.c +++ b/tools/regression/sockets/unix_close_race/unix_close_race.c @@ -54,12 +54,13 @@ #include <unistd.h> #include <err.h> -#define UNIXSTR_PATH "/tmp/mytest.socket" +static char socket_path[] = "tmp.XXXXXXXX"; + #define USLEEP 100 #define LOOPS 100000 int -main(int argc, char **argv) +main(void) { struct sockaddr_un servaddr; int listenfd, connfd, pid; @@ -74,16 +75,20 @@ main(int argc, char **argv) if (ncpus < 2) warnx("SMP not present, test may be unable to trigger race"); + if (mkstemp(socket_path) == -1) + err(1, "mkstemp failed"); + unlink(socket_path); + /* * 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"); - (void)unlink(UNIXSTR_PATH); + (void)unlink(socket_path); bzero(&servaddr, sizeof(servaddr)); servaddr.sun_family = AF_LOCAL; - strcpy(servaddr.sun_path, UNIXSTR_PATH); + strcpy(servaddr.sun_path, socket_path); if (bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) err(1, "parent: bind error"); @@ -102,7 +107,7 @@ main(int argc, char **argv) sleep(1); bzero(&servaddr, sizeof(servaddr)); servaddr.sun_family = AF_LOCAL; - strcpy(servaddr.sun_path, UNIXSTR_PATH); + strcpy(servaddr.sun_path, socket_path); for (counter = 0; counter < LOOPS; counter++) { if ((connfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) { (void)kill(pid, SIGTERM); |