summaryrefslogtreecommitdiffstats
path: root/lib/libssl
diff options
context:
space:
mode:
authorbcook <bcook@openbsd.org>2014-10-13 02:39:09 +0000
committerbcook <bcook@openbsd.org>2014-10-13 02:39:09 +0000
commitfcc700e73b57e59b27043f1b994ff05cfa857343 (patch)
treeac08f9722198a3bba41713e1430c1ce3ab5723c0 /lib/libssl
parentjmc@ told me i broke the documentation. inetd doesnt write a pidfile so (diff)
downloadwireguard-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/libssl')
-rw-r--r--lib/libssl/src/crypto/bio/b_sock.c10
1 files changed, 8 insertions, 2 deletions
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);
}