diff options
author | florian | 2014-09-19 21:28:32 +0000 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-05-24 12:33:55 +0200 |
commit | c5352791a6936f9c42e9895464ee77761abff3cc (patch) | |
tree | f87fdc36f631f2b8ae6e2ea20110a5738e11a347 /slowcgi.c | |
parent | fc4a4d3f15e02590e1a00caab5772274889b3867 (diff) | |
download | slowcgi-c5352791a6936f9c42e9895464ee77761abff3cc.tar.gz |
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 'slowcgi.c')
-rw-r--r-- | slowcgi.c | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -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"); |