diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2023-01-09 22:10:30 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2023-01-13 00:37:38 -0500 |
commit | 2246731177cdc0a8325dd3d58a17f508604303b0 (patch) | |
tree | 182a53574a6051687d262b50dfec40b3226d276b | |
parent | 08d2cda776490db1cd95b14b98e062e3e9ff44ac (diff) | |
download | lighttpd-git-2246731177cdc0a8325dd3d58a17f508604303b0.tar.gz |
[core] avoid accept4() on ARM unless detected
accept4() was added in Linux x86 in kernel 2.6.28
accept4() was added in Linux ARM in kernel 2.6.36
Depending on the build environment, this patch may result in lighttpd
using accept() on some ARM systems where accept4() is available, but
should avoid the prior situation on ancient systems where accept4()
fails at runtime due to libc support present but kernel support missing.
x-ref:
"Not need for new syscall"
https://lwn.net/Articles/789961/
"accept4 returns EPERM instead of ENOSYS on some platforms"
https://redmine.lighttpd.net/issues/2998
"cross-compilation for blackfin processor"
https://redmine.lighttpd.net/boards/2/topics/10772
-rw-r--r-- | src/fdevent.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/fdevent.c b/src/fdevent.c index acf3dd83..ec68471d 100644 --- a/src/fdevent.c +++ b/src/fdevent.c @@ -283,6 +283,20 @@ int fdevent_mkostemp(char *path, int flags) { } +/* accept4() added in Linux x86 in kernel 2.6.28, but not in arm until 2.6.36 + * https://lwn.net/Articles/789961/ */ +#if defined(__linux__) \ + && (defined(__arm__) || defined(__thumb__) || defined(__arm64__)) +#ifdef __has_include +#if __has_include(<sys/syscall.h>) +#include <sys/syscall.h> +#endif +#endif +#ifndef SYS_accept4 +#define accept4(a,b,c,d) ((errno = ENOTSUP), -1) +#endif +#endif + int fdevent_accept_listenfd(int listenfd, struct sockaddr *addr, size_t *addrlen) { int fd; socklen_t len = (socklen_t) *addrlen; |