_WIN32_WINNT and WIN32_LEAN_AND_MEAN need to be defined
before the windows.h is included for the first time.
Avoid the confusion of indirect #include by defining
before any.
Now, it 20min for sequential runs is not enough already, I've tested it
on t3.medium manually and got the same:
Total Test time (real) = 1275.03 sec
And also if I run tests in parallel then I had few failures:
bufferevent/bufferevent_connect_fail:
FAIL /root/libevent/test/regress_bufferevent.c:865: didn't fail? what 128
FAIL /root/libevent/test/regress_bufferevent.c:906: assert(test_ok == 1): 0 vs 1
FAIL /root/libevent/test/regress_bufferevent.c:839: assert(n_events_invoked == 1): 2 vs 1bufferevent/bufferevent_connect_fail_eventcb_defer:
FAIL /root/libevent/test/regress_bufferevent.c:839: assert(n_events_invoked == 1): 2 vs 1bufferevent/bufferevent_connect_fail_eventcb: 3/386 TESTS FAILED. (45 skipped)
v2: Increase timeout more (for netbsd)
signalfd may behave differently to sigaction/signal, so to avoid
breaking libevent users (like [1], [2]) disable it by default.
[1]: https://github.com/tmux/tmux/pull/3621
[2]: https://github.com/tmux/tmux/pull/3626
Also signalfd is not that perfect:
- you need to SIG_BLOCK the signal before
- blocked signals are not reset on exec
- blocked signals are allowed to coalesce - so in case of multiple
signals sent you may get the signal only once (ok for most of the
signals, but may be a problem for SIGCHLD, though you may call
waitpid() in a loop or use pidfd)
- and also one implementation problem -
sigprocmask is unspecified in a multithreaded process
Refs:
- https://lwn.net/Articles/415684/
- https://ldpreload.com/blog/signalfd-is-useless
Refs: https://github.com/libevent/libevent/issues/1460
Refs: #1342 (cc @dmantipov)
I faced with strange problem: event loop doesn't exit after dns resolving with
`EVDNS_BASE_DISABLE_WHEN_INACTIVE`.
Stand:
- Ubuntu 22;
- libevent release-2.1.12-stable
- `resolve.conf` contains 2 nameservers;
- I use `evdns_base_new` with `EVDNS_BASE_DISABLE_WHEN_INACTIVE | EVDNS_BASE_INITIALIZE_NAMESERVERS` to avoid OS specific code.
After small investigation, look like events related with dns sockets added to
event_base before `evdns->disable_when_inactive` was initialized. `libevent`
did epoll_ctl(DEL) after resolving completed on the first socket, but the
second socket remained in the `epoll` interest list.
The benefit of this optimization is questionable for the following
reasons:
- libevent uses CLOCK_MONOTONIC_COARSE which is fast enough (on my
desktop CLOCK_MONOTONIC/CLOCK_MONOTONIC_RAW works 40/50 millions of
ops per second, and CLOCK_MONOTONIC_COARSE is faster)
- libevent has caching of time (EVENT_BASE_FLAG_NO_CACHE_TIME)
So I don't see any reason for using one more caching - lazy comparsion
(whatever you call it).
This replaces malloc and free in wepoll.c with mm_malloc and mm_free. I'm using event-internal.h instead of mm-internal.h. Using only mm-internal.h in wepoll.c can cause errors regarding the export symbol macros.
Both cmake and autoconf are capable of automatically detecting the presence of OpenSSL and MbedTLS. However, the present build time logic doesn't do this.
With cmake, my starting point is to preserve the reversed logic of `EVENT__DISABLE_OPENSSL` and `EVENT__DISABLE_MBEDTLS`, adding a third option `AUTO` as the new default. I'm following the pattern of this [post on the cmake list](https://cmake.org/pipermail/cmake/2016-October/064342.html). `OFF` and `ON` should continue with their present behaviors.
With autoconf, I've tried to implement what I understand to be conventional behavior. eg. `--enable-openssl` and `--disable-openssl` should continue to have the same effect. The default if neither is passed is equivalent to the new `--enable-openssl=auto`.
I've also added another commit removing what I think is an unnecessary `break` in `m4/libevent_mbedtls.m4`, which I suspect is leftover from some copy+paste from `m4/libevent_openssl.m4`. Surprisingly to me, a `break` outside of any loop does not seem to be treated as an error.
I've created the SECURITY.md file following a GitHub's template and considering the report vulnerability through security advisory, which is a handy new GitHub feature (but it's still in beta and has to be enabled).
Closes#1461
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
* changelog-improvements:
Generate changelog in a reverse order
Add PR number into the changelog
Use authors of the real patches instead of merge commits
Cleanup changelog.py
After rebasing I broke the initial intention of this patch, so it simply
should be reverted.
This reverts commit 81c6b8823c1b58d7837e827bb1098aa5f9e5956b.
* ssl-read-pull:
ssl: add some comments for lack of notify_close
Drop unused le_ssl_ops::err_is_ok
More SSL_read() to fill big buffer
Make bufferevent_set_max_single_read() effect
Once SSL_read() only get max 16K bytes (one TLS record).
In case of big buffer, should more SSL_read() to fill the buffer.
Using sample https-client to measure max income MBit/s via nload tool.
Note: set bufferevent_set_max_single_read() by 32K and add the chunk
callback to read out each piece of data.
The client sample do https request a data 900KB (the server don't use
Transfer-Encoding: chunked)
- With origin/master: max income is 2.26 MBit/s
The chunk callback never get a piece of data > 16K.
- With this PR: max income is 2.44 MBit/s
The chunk callback can get some piece of data 32K or more.
The generated configurations for both CMake and pkg-config included
absolute paths to dependencies (OpenSSL, MbedTLS). This is contrary
to the general CMake advise to create relocatable packages [1].
Additionally, when building both mbedtls and libevent via CMake's
FetchContent in the same project, loading the project would fail with
INTERFACE_INCLUDE_DIRECTORIES property contains path:
"/home/user/project/cmake-build/_deps/mbedtls-build/include"
which is prefixed in the source directory.
The required changes include:
- Adding the outer includes only to the BUILD_INTERFACE solves the
makes the CMake paths relocatable and thus solves the FetchContent
problem.
- Updates to libevent_*.pc.in fixes the relocatable issues for
pkg-config and properly declares currently missing dependencies.
- Using components for linking to OpenSSL (requiring CMake 3.4)
and MbedTLS. The new MbedTLS target names now match the component
names of the MbedTLS' CMake project.
- Use the Threads CMake library reference instead of a direct
reference to support both built-in pthread and -lpthread.
v2 (azat): get back CMAKE_REQUIRED_LIBRARIES
[1] https://cmake.org/cmake/help/v3.25/manual/cmake-packages.7.html#creating-relocatable-packages