diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-11-23 20:56:16 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2015-11-23 20:56:16 +0000 |
commit | fff4174d838087f7eb83411369928f00a377e6ba (patch) | |
tree | 0bfcd12611418e240ce428b949592183b561e18c /usr.sbin/httpd/control.c | |
parent | 59cfb780f83cebcd070410eff4bfc4c29254ec14 (diff) |
Retire socket_set_blockmode() in favor of the SOCK_NONBLOCK type flag.
As done in iked and snmpd.
OK jung@
Diffstat (limited to 'usr.sbin/httpd/control.c')
-rw-r--r-- | usr.sbin/httpd/control.c | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c index 5c715454458..f3f462eac6c 100644 --- a/usr.sbin/httpd/control.c +++ b/usr.sbin/httpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.7 2015/05/28 17:08:08 florian Exp $ */ +/* $OpenBSD: control.c,v 1.8 2015/11/23 20:56:14 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -50,7 +50,7 @@ control_init(struct privsep *ps, struct control_sock *cs) if (cs->cs_name == NULL) return (0); - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) == -1) { log_warn("%s: socket", __func__); return (-1); } @@ -93,7 +93,6 @@ control_init(struct privsep *ps, struct control_sock *cs) return (-1); } - socket_set_blockmode(fd, BM_NONBLOCK); cs->cs_fd = fd; cs->cs_env = env; @@ -143,8 +142,8 @@ control_accept(int listenfd, short event, void *arg) return; len = sizeof(sun); - if ((connfd = accept(listenfd, - (struct sockaddr *)&sun, &len)) == -1) { + if ((connfd = accept4(listenfd, + (struct sockaddr *)&sun, &len, SOCK_NONBLOCK)) == -1) { /* * Pause accept if we are out of file descriptors, or * libevent will haunt us here too. @@ -160,8 +159,6 @@ control_accept(int listenfd, short event, void *arg) return; } - socket_set_blockmode(connfd, BM_NONBLOCK); - if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) { close(connfd); log_warn("%s: calloc", __func__); @@ -314,20 +311,3 @@ control_imsg_forward(struct imsg *imsg) 0, imsg->hdr.pid, -1, imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE); } - -void -socket_set_blockmode(int fd, enum blockmodes bm) -{ - int flags; - - if ((flags = fcntl(fd, F_GETFL, 0)) == -1) - fatal("fcntl F_GETFL"); - - if (bm == BM_NONBLOCK) - flags |= O_NONBLOCK; - else - flags &= ~O_NONBLOCK; - - if ((flags = fcntl(fd, F_SETFL, flags)) == -1) - fatal("fcntl F_SETFL"); -} |