diff options
author | 2014-10-13 02:39:09 +0000 | |
---|---|---|
committer | 2014-10-13 02:39:09 +0000 | |
commit | fcc700e73b57e59b27043f1b994ff05cfa857343 (patch) | |
tree | ac08f9722198a3bba41713e1430c1ce3ab5723c0 /lib | |
parent | jmc@ told me i broke the documentation. inetd doesnt write a pidfile so (diff) | |
download | wireguard-openbsd-fcc700e73b57e59b27043f1b994ff05cfa857343.tar.xz wireguard-openbsd-fcc700e73b57e59b27043f1b994ff05cfa857343.zip |
Use O_NONBLOCK over FIONBIO.
Prefer this because it is the POSIX standard and has consistent behavior
across platforms.
Use BIO_socket_nbio consistently across the tree.
from Jonas 'Sortie' Termansen, ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/bio/b_sock.c | 10 | ||||
-rw-r--r-- | lib/libssl/src/crypto/bio/b_sock.c | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c index c095943e8b9..81c48a6e5c6 100644 --- a/lib/libcrypto/bio/b_sock.c +++ b/lib/libcrypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.56 2014/07/16 10:43:06 deraadt Exp $ */ +/* $OpenBSD: b_sock.c,v 1.57 2014/10/13 02:39:09 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,6 +65,7 @@ #include <netinet/tcp.h> #include <errno.h> +#include <fcntl.h> #include <limits.h> #include <netdb.h> #include <stdio.h> @@ -459,5 +460,10 @@ BIO_set_tcp_ndelay(int s, int on) int BIO_socket_nbio(int s, int mode) { - return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); + int flags = fcntl(s, F_GETFD); + if (mode && !(flags & O_NONBLOCK)) + return (fcntl(s, F_SETFL, flags | O_NONBLOCK) == 0); + else if (!mode && (flags & O_NONBLOCK)) + return (fcntl(s, F_SETFL, flags & ~O_NONBLOCK) == 0); + return (1); } diff --git a/lib/libssl/src/crypto/bio/b_sock.c b/lib/libssl/src/crypto/bio/b_sock.c index c095943e8b9..81c48a6e5c6 100644 --- a/lib/libssl/src/crypto/bio/b_sock.c +++ b/lib/libssl/src/crypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.56 2014/07/16 10:43:06 deraadt Exp $ */ +/* $OpenBSD: b_sock.c,v 1.57 2014/10/13 02:39:09 bcook Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,6 +65,7 @@ #include <netinet/tcp.h> #include <errno.h> +#include <fcntl.h> #include <limits.h> #include <netdb.h> #include <stdio.h> @@ -459,5 +460,10 @@ BIO_set_tcp_ndelay(int s, int on) int BIO_socket_nbio(int s, int mode) { - return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); + int flags = fcntl(s, F_GETFD); + if (mode && !(flags & O_NONBLOCK)) + return (fcntl(s, F_SETFL, flags | O_NONBLOCK) == 0); + else if (!mode && (flags & O_NONBLOCK)) + return (fcntl(s, F_SETFL, flags & ~O_NONBLOCK) == 0); + return (1); } |