In buffer.c a variable "flags" and a label "done" are defined but
never used if "EVENT__HAVEMMAP" is not defined.
The code does not work on platforms which do not provide
the function `socketpair()`. Introduce EVENT__HAVE_SOCKETPAIR flag
which determines if `socketpair()` or `evutil_ersatz_socketpair()`
is used.
If pread(2) is available, prefer it over double lseek(2)
and read(2) in evbuffer_file_segment_materialize().
Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Linux-specific signal handling backend based on signalfd(2)
system call, and public function event_base_get_signal_method()
to obtain an underlying kernel signal handling mechanism.
Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Since new compilers has new checks (like -Wdangling-pointer), and so to
avoid extra checks in cmake/autotools, simply suppress if the pragma is
unknown.
This adds few functions to use evhttp-based webserver to handle incoming
WebSockets connections. We've tried to use both libevent and libwebsockets in
our application, but found that we need to have different ports at the same
time to handle standard HTTP and WebSockets traffic. This change can help to
stick only with libevent library.
Implementation was inspired by modified Libevent source code in ipush project
[1].
[1]: https://github.com/sqfasd/ipush/tree/master/deps/libevent-2.0.21-stable
Also, WebSocket-based chat server was added as a sample.
There can be issues on 32-bit architectures to mmap 2+GiB file, and to
make this portable between different version of glibc, mmap64 was
prefered over _FILE_OFFSET_BITS
Error
configure.ac:291: warning: AC_CHECK_FUNCS(getnameinfo
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(getprotobynumber
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(getservbyname
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(inet_ntop
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(inet_pton
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
Otherwise build fails [1]:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/minheap-internal.h:64:6: error: ‘min_heap_ctor_’ defined but not used [-Werror=unused-function]
void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
^~~~~~~~~~~~~~
In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:91:0:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/bufferevent-internal.h:414:1: error: ‘bufferevent_trigger_nolock_’ defined but not used [-Werror=unused-function]
bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:89:0:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/evthread-internal.h:140:1: error: ‘EVLOCK_TRY_LOCK_’ defined but not used [-Werror=unused-function]
EVLOCK_TRY_LOCK_(void *lock)
[1]: https://github.com/libevent/libevent/runs/7263518180?check_suite_focus=true
Otherwise GCC will warn. i.e:
```bash
CCLD libevent_openssl.la
cc1: note: unrecognized command-line option ‘-Wno-void-pointer-to-enum-cast’
may have been intended to silence earlier diagnostics
CCLD libevent_mbedtls.la
```
> By default, configure sets the prefix for files it installs to /usr/local.
A call to AC_PREFIX_DEFAULT, just to set the value the same as the
default, would seem unnecessary. Note that the "initialize prefix"
comment dates back to aa6567fe6475d3230c7c745a7ca208735af0c331, prior to
when an autoconf macro was actually being used.
See:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#Default-Prefix.
Fixes: d433f847 ("Revert "build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS"")
Fixes: 28f0fe6f ("build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS")
Fixes: ce028cef ("build: fix autotools build under mingw")
That commit was wrong, it breaks syntax for autoconf <2.71, since
AC_CHECK_*S() requires sh-like list.
This reverts commit 28f0fe6fd1e2b1e9fb24a5c7a5b078790890e44f.
Fixes: #1149
autoconf 2.72 reports:
configure.ac:188: warning: AC_CHECK_HEADERS(\
): you should use literals
../autoconf-2.71/lib/autoconf/headers.m4:217: AC_CHECK_HEADERS is expanded from...
configure.ac:188: the top level
configure.ac:188: warning: AC_CHECK_HEADERS(afunix.h
): you should use literals
And also it fails to find fcntl.h and other headers because of this:
configure:14725: checking for fcntl.h
configure:14725: gcc -c -I/mingw64/include conftest.c >&5
conftest.c:77:10: fatal error: fcntl.h: No such file or directory
77 | #include < fcntl.h>
Refs: https://github.com/libevent/libevent/pull/1146/checks?check_run_id=2211752215
autotools that is shipped with mingw (autoconf 2.71-1, automake
1.6-1.16, automake wrapper 11-1), does not allow trailing backslashes
for AC_CHECK_HEADERS() and AC_CHECK_FUNCS(), otherwise it generates
incorrect for loop, and reports:
../configure: line 14724: syntax error near unexpected token `as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`'
../configure: line 14724: ` as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`'
Error: Process completed with exit code 1.
Here is a simple analog:
for VAR in <CR> foo \ <CR> bar \
do :
echo $VAR
done
Trailing slash is not allowed.
Refs:
- https://github.com/libevent/libevent/runs/2171607687
- https://github.com/libevent/libevent/runs/2211365885?check_suite_focus=true
Looks like a `splice` implementation was planned, but has clearly never
eventuated (the TODO comment is from ~12 years ago, in
8b5bd77415fb6634fadf08357676926fecf5f032). For now, it's probably better
to remove the unused code/correct the docs.
AC_HAVE_LIBRARY is deprecated, see
https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Obsolete-Macros.html,
and has been prior to Autoconf 2.67, which is the minimum required by
the project. It's usage also causes warnings with newer versions of autoconf:
```bash
configure.ac:319: warning: The macro `AC_HAVE_LIBRARY' is obsolete.
configure.ac:319: You should run autoupdate.
```
`AC_HAVE_LIBRARY` was introduced in #969, although it's not clear why it
was decided to revert to using an obselete macro.
Rather than trying to detect (potentially very old) GCC versions, just
test whether the flag works with the compiler, and add it to CLFAGS if
so.
-Werror is used to convert unknown flag warnings into errors, and
prevent their addition to CLFAGS.
libevent is lacking a scalable backend on Windows. Let's leverage the wepoll
library until Windows comes up with an epoll/kqueue compete user mode API.
- All regress tests pass for standard wepoll
- These 2 tests fail intermittently for changelist wepoll, so disabling
changelist wepoll for now
http/cancel_inactive_server
http/stream_in
- verify target on Windows runs tests for both wepoll and win32 backends
- wepoll backend preferred over win32 backend
- wepoll version 1.5.6
v2: cleaner backend abstraction. Disallow wepoll on MinGW/Cygwin.
v3: Add wepoll.h to dist
v4: Make sure wepoll source files are excluded from cygwin/mingw builds
v5: Keep win32 as default backend on windows.
v6: Include wepoll in mingw builds. Verified that regress tests pass w/ WEPOLL backend.
v7: Enable wepoll on mingw when building with cmake
v8: Add wepoll testrunner for autotools test target