diff options
author | Brent Cook <bcook@cvs.openbsd.org> | 2014-10-13 02:39:10 +0000 |
---|---|---|
committer | Brent Cook <bcook@cvs.openbsd.org> | 2014-10-13 02:39:10 +0000 |
commit | 14a0e6de88272b088e9c555f9dfebf338cfceade (patch) | |
tree | e2f09731b5281540c4296dba78afe9ffb9cf0988 /lib/libcrypto/bio/b_sock.c | |
parent | 6fbb20eb585c947850e2e7f85a8000bbb734755c (diff) |
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/libcrypto/bio/b_sock.c')
-rw-r--r-- | lib/libcrypto/bio/b_sock.c | 10 |
1 files changed, 8 insertions, 2 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); } |