diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2014-09-19 21:28:33 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2014-09-19 21:28:33 +0000 |
commit | 4d2138dc2257588d7adc50930524030052d2f9af (patch) | |
tree | 4f22f7e010ffbafb96836878d8981986a8920145 /usr.sbin/slowcgi/slowcgi.c | |
parent | 8cabda8ec0e797cb869e8400d594ff5b45a648cf (diff) |
Instead of doing the fcntl(2) and ioctl(2) song and dance just tell
socket(2) and accept4(2) that we want non-blocking-close-on-exec
sockets.
OK benno@
Diffstat (limited to 'usr.sbin/slowcgi/slowcgi.c')
-rw-r--r-- | usr.sbin/slowcgi/slowcgi.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index 7e66d16bc4f..445cf864bf1 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.34 2014/07/13 21:46:25 claudio Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.35 2014/09/19 21:28:32 florian Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -358,9 +358,9 @@ slowcgi_listen(char *path, struct passwd *pw) mode_t old_umask, mode; int fd; - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) + if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, + 0)) == -1) lerr(1, "slowcgi_listen: socket"); - fcntl(fd, F_SETFD, FD_CLOEXEC); bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; @@ -384,9 +384,6 @@ slowcgi_listen(char *path, struct passwd *pw) if (chown(path, pw->pw_uid, pw->pw_gid) == -1) lerr(1, "slowcgi_listen: chown: %s", path); - if (ioctl(fd, FIONBIO, &on) == -1) - lerr(1, "listener ioctl(FIONBIO)"); - if (listen(fd, 5) == -1) lerr(1, "listen"); @@ -420,7 +417,8 @@ accept_reserve(int sockfd, struct sockaddr *addr, socklen_t *addrlen, return -1; } - if ((ret = accept(sockfd, addr, addrlen)) > -1) { + if ((ret = accept4(sockfd, addr, addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC)) + > -1) { (*counter)++; ldebug("inflight incremented, now %d", *counter); } @@ -461,10 +459,6 @@ slowcgi_accept(int fd, short events, void *arg) } } - fcntl(s, F_SETFD, FD_CLOEXEC); - if (ioctl(s, FIONBIO, &on) == -1) - lerr(1, "request ioctl(FIONBIO)"); - c = calloc(1, sizeof(*c)); if (c == NULL) { lwarn("cannot calloc request"); |