diff options
author | Garrett D'Amore <garrett@damore.org> | 2016-10-20 11:29:40 -0700 |
---|---|---|
committer | Garrett D'Amore <garrett@damore.org> | 2016-10-20 11:29:40 -0700 |
commit | 21b8cd0c7e0edc704ab58d869eba600fc3b67261 (patch) | |
tree | 0b25b598b98b7b9ce250795909c69c08a4f9fb09 | |
parent | cadd0d933bc7fba435f5e857759c178c679c16e6 (diff) | |
download | nanomsg-21b8cd0c7e0edc704ab58d869eba600fc3b67261.tar.gz |
fixes #800 accept4 not implemented on all systems
-rw-r--r-- | src/aio/usock_posix.inc | 5 | ||||
-rw-r--r-- | src/utils/efd_pipe.inc | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/aio/usock_posix.inc b/src/aio/usock_posix.inc index 2f8d1c3..c19f5db 100644 --- a/src/aio/usock_posix.inc +++ b/src/aio/usock_posix.inc @@ -329,6 +329,11 @@ void nn_usock_accept (struct nn_usock *self, struct nn_usock *listener) /* Try to accept new connection in synchronous manner. */ #if NN_HAVE_ACCEPT4 s = accept4 (listener->s, NULL, NULL, SOCK_CLOEXEC); + if ((s < 0) && (errno == ENOTSUP)) { + /* Apparently some old versions of Linux have a stub for this in libc, + without any of the underlying kernel support. */ + s = accept (listener->s, NULL, NULL); + } #else s = accept (listener->s, NULL, NULL); #endif diff --git a/src/utils/efd_pipe.inc b/src/utils/efd_pipe.inc index eeb8891..408d77f 100644 --- a/src/utils/efd_pipe.inc +++ b/src/utils/efd_pipe.inc @@ -38,6 +38,10 @@ int nn_efd_init (struct nn_efd *self) #if defined NN_HAVE_PIPE2 rc = pipe2 (p, O_NONBLOCK | O_CLOEXEC); + if ((rc == -1) && (errno == ENOTSUP)) { + /* Deal with unimplemented system call/libc mismatch (Linux). */ + rc = pipe (p); + } #else rc = pipe (p); #endif |