diff options
| author | bcook <> | 2014-10-13 02:39:09 +0000 |
|---|---|---|
| committer | bcook <> | 2014-10-13 02:39:09 +0000 |
| commit | e2a3519b1b62c76a0286e3bef886f0b0cde58634 (patch) | |
| tree | 70c469b77c3b1769a4552537e8f7a18cbb3e5ef8 /src/lib/libc | |
| parent | 7c6875aa96e2c3ef7b8f7cca8a49601fbca7b5b5 (diff) | |
| download | openbsd-e2a3519b1b62c76a0286e3bef886f0b0cde58634.tar.gz openbsd-e2a3519b1b62c76a0286e3bef886f0b0cde58634.tar.bz2 openbsd-e2a3519b1b62c76a0286e3bef886f0b0cde58634.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 '')
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 10 |
1 files changed, 8 insertions, 2 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) | |||
| 459 | int | 460 | int |
| 460 | BIO_socket_nbio(int s, int mode) | 461 | BIO_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 | } |
