diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2019-03-04 21:59:47 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2019-03-07 00:32:17 -0500 |
commit | 1fb0d7e295669d59b56679868df8f8724d4dc5af (patch) | |
tree | 3f0ea72a2dc4e0ea1d35ec6a2bb59f06aa3b532f /src/fdevent.c | |
parent | 28895ab2972acc05d4986fb2328c559d26301c01 (diff) | |
download | lighttpd-git-1fb0d7e295669d59b56679868df8f8724d4dc5af.tar.gz |
[core] no SOCK_NONBLOCK on QNX 7.0
QNX 7.0 has SOCK_CLOEXEC but not SOCK_NONBLOCK
(thx supergaute)
github: closes #98
x-ref:
"Fix compile error when system has SOCK_CLOEXEC but not SOCK_NONBLOCK"
https://github.com/lighttpd/lighttpd1.4/pull/98
Diffstat (limited to 'src/fdevent.c')
-rw-r--r-- | src/fdevent.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/fdevent.c b/src/fdevent.c index 2aaa6a57..6f7d3577 100644 --- a/src/fdevent.c +++ b/src/fdevent.c @@ -165,10 +165,16 @@ fdevents *fdevent_init(server *srv) { * (reported on Android running a custom ROM) * https://redmine.lighttpd.net/issues/2883 */ + #ifdef SOCK_NONBLOCK int fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0); + #else + int fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); + #endif if (fd >= 0) { int flags = fcntl(fd, F_GETFL, 0); + #ifdef SOCK_NONBLOCK use_sock_nonblock = (-1 != flags && (flags & O_NONBLOCK)); + #endif use_sock_cloexec = 1; close(fd); } @@ -454,8 +460,18 @@ int fdevent_socket_cloexec(int domain, int type, int protocol) { int fdevent_socket_nb_cloexec(int domain, int type, int protocol) { int fd; #ifdef SOCK_CLOEXEC + #ifdef SOCK_NONBLOCK if (use_sock_cloexec && use_sock_nonblock) return socket(domain, type | SOCK_CLOEXEC | SOCK_NONBLOCK, protocol); + #else + if (use_sock_cloexec) { + fd = socket(domain, type | SOCK_CLOEXEC, protocol); + #ifdef O_NONBLOCK + if (-1 != fd) force_assert(-1 != fcntl(fd,F_SETFL,O_NONBLOCK|O_RDWR)); + #endif + return fd; + } + #endif #endif if (-1 != (fd = socket(domain, type, protocol))) { #ifdef FD_CLOEXEC |