summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorbcook <>2014-10-13 02:39:09 +0000
committerbcook <>2014-10-13 02:39:09 +0000
commit7b944af97196f9b4b28af3b73db474a465f413a6 (patch)
tree70c469b77c3b1769a4552537e8f7a18cbb3e5ef8 /src/lib
parent188e36185aae11a52b07f29de8b1334484bac87e (diff)
downloadopenbsd-7b944af97196f9b4b28af3b73db474a465f413a6.tar.gz
openbsd-7b944af97196f9b4b28af3b73db474a465f413a6.tar.bz2
openbsd-7b944af97196f9b4b28af3b73db474a465f413a6.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 'src/lib')
-rw-r--r--src/lib/libcrypto/bio/b_sock.c10
-rw-r--r--src/lib/libssl/src/crypto/bio/b_sock.c10
2 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index c095943e8b..81c48a6e5c 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.56 2014/07/16 10:43:06 deraadt Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.57 2014/10/13 02:39:09 bcook Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,6 +65,7 @@
65#include <netinet/tcp.h> 65#include <netinet/tcp.h>
66 66
67#include <errno.h> 67#include <errno.h>
68#include <fcntl.h>
68#include <limits.h> 69#include <limits.h>
69#include <netdb.h> 70#include <netdb.h>
70#include <stdio.h> 71#include <stdio.h>
@@ -459,5 +460,10 @@ BIO_set_tcp_ndelay(int s, int on)
459int 460int
460BIO_socket_nbio(int s, int mode) 461BIO_socket_nbio(int s, int mode)
461{ 462{
462 return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); 463 int flags = fcntl(s, F_GETFD);
464 if (mode && !(flags & O_NONBLOCK))
465 return (fcntl(s, F_SETFL, flags | O_NONBLOCK) == 0);
466 else if (!mode && (flags & O_NONBLOCK))
467 return (fcntl(s, F_SETFL, flags & ~O_NONBLOCK) == 0);
468 return (1);
463} 469}
diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c
index c095943e8b..81c48a6e5c 100644
--- a/src/lib/libssl/src/crypto/bio/b_sock.c
+++ b/src/lib/libssl/src/crypto/bio/b_sock.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: b_sock.c,v 1.56 2014/07/16 10:43:06 deraadt Exp $ */ 1/* $OpenBSD: b_sock.c,v 1.57 2014/10/13 02:39:09 bcook Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -65,6 +65,7 @@
65#include <netinet/tcp.h> 65#include <netinet/tcp.h>
66 66
67#include <errno.h> 67#include <errno.h>
68#include <fcntl.h>
68#include <limits.h> 69#include <limits.h>
69#include <netdb.h> 70#include <netdb.h>
70#include <stdio.h> 71#include <stdio.h>
@@ -459,5 +460,10 @@ BIO_set_tcp_ndelay(int s, int on)
459int 460int
460BIO_socket_nbio(int s, int mode) 461BIO_socket_nbio(int s, int mode)
461{ 462{
462 return (BIO_socket_ioctl(s, FIONBIO, &mode) == 0); 463 int flags = fcntl(s, F_GETFD);
464 if (mode && !(flags & O_NONBLOCK))
465 return (fcntl(s, F_SETFL, flags | O_NONBLOCK) == 0);
466 else if (!mode && (flags & O_NONBLOCK))
467 return (fcntl(s, F_SETFL, flags & ~O_NONBLOCK) == 0);
468 return (1);
463} 469}