In commit f8bb9d8 the header stringapiset.h was included, very likely because the user who made the change saw that the funciton WideCharToMultiByte is "declared" in there.
That header tho is a recent addition to the windows headers added in the last years in an attempt from microsoft to split the windows.h header in multiple files, so the inclusion fails when the library is not built with the latest visual studio using the latest windows 10 sdk.
That inclusion can be safely removed as in any case the function WideCharToMultiByte was already included by the windows.h header that is included few lines below.
* tests-fixes:
Add more ignore rules
test: fix debug locks in case new lock gots old address
test: suppress logs from the tests that produce them under normal circumstances
test: fix TT_* flags values
Suppress data race for test_ok variable
Suppress data race for event_debug_created_threadable_ctx_ variable
Libevent introduced the LEV_OPT_BIND_IPV6ONLY to pass to evconnlistener_new_bind to make it automatically set the underlying socket as accepting ipv6 requests. This works fine on posix compliant platforms as by the standard every new AF_INET6 socket is created as both supporting ipv6 and ipv4 connections. But on windows the default is the opposite, with the flag IPV6_V6ONLY being always enabled by default.
This makes creating a listener to supports both protocols a bit more tricky as winsock doesn't allow changing this flag after evconnlistener_new_bind does all the initial setup because as stated in the docs, you can't change it after the sonnect connected, so one would have to manually create the socket beforehand and set the flag and then call evconnlistener_new with the socket itself.
It would be nice to have libevent keep a consistent behaviour across the platforms in this scenario, maybe or by making it always set IPV6_V6ONLY to false unless LEV_OPT_BIND_IPV6ONLY is passed, in which case it's set to true, or add another flag to forcefully set it to false and keep the system dependent behaviour as default.
So this patch add new option for libevent listeners to bind to both - LEV_OPT_BIND_IPV4_AND_IPV6
- -Wdeprecated-non-prototype
/src/le/libevent/strlcpy.c:48:1: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
event_strlcpy_(dst, src, siz)
- -Wstrict-prototypes
/src/le/libevent/evthread.c:82:70: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
struct evthread_condition_callbacks *evthread_get_condition_callbacks()
- -Wunused-but-set-variable
/src/le/libevent/test/regress_buffer.c:130:6: warning: variable 'n' set but not used [-Wunused-but-set-variable]
int n = 0;
^
* evdns-no-ns:
Allow evdns_base_new to succeed with no nameservers configured
Replace magic numbers with consts for evdns_base_resolv_conf_parse() errors
If resolv.conf has no nameservers, evdns_base_new can still succeed with
the default of using the name server from localhost matching the man
page documentation for resolv.conf.
arc4random() defines with __wur (warn-unused-return) macro in glibc, but
the problem pops up only for gentoo, since only it really define __wur
to __attribute__ ((__warn_unused_result__)), because it defines
_FORTIFY_SOURCE unconditionally [1].
[1]: https://gitweb.gentoo.org/proj/gcc-patches.git/tree/9.4.0/gentoo/01_all_default-fortify-source.patch?id=7f7f80a650607c3090ae0790b8daef88434da681
And hence you get this error:
```sh
docker run -v $PWD:/src:ro --rm --name le -w /src -it gentoo/stage3 bash -c 'mkdir /build && cd /build && /src/configure --enable-gcc-warnings=yes --disable-samples && make -j && echo OK'
/src/evutil_rand.c: In function 'evutil_secure_rng_init':
/src/evutil_rand.c:56:16: error: ignoring return value of 'arc4random' declared with attribute 'warn_unused_result' [-Werror=unused-result]
56 | (void) arc4random();
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:2056: evutil_rand.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/build'
make: *** [Makefile:1523: all] Error 2
```
Also it seems that GCC works as expected here [2], and will not change
the behavior.
[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
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>
This patch excludes definition of arc4random_buf on systems where it is already present. When the symbol is found, the macro EVENT__HAVE_ARC4RANDOM_BUF is set via CMake's configure_file(..).
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
the allocation of the struct deferred_reply_callback can fail. If that
happens a program waiting for a callback never gets a callback. The
program would asume that it either gets an error or a callback when e.g.
calling evdns_base_resolve_ipv6.
I did an analysis of the evdns.c code and concluded that struct
evdns_request would live until the callback is executed. Based on that
conclusion I removed the struct deferred_reply_callback and moved the
neccessary fields for data which should be copied from struct request
into struct evdns_request.
The fields evdns_callback_type user_callback and void *user_pointer are
moved into struct evdns_request as it is a more natural place for them
to live than struct request.
Initially 6.9 and 7.1 had been added, however due to some issues (you can read
about them below) 6.9 had been disabled.
netbsd 6.9 does not have correct library namings for autotools:
2022-08-17T04:59:58.8339420Z libtool: link: (cd ".libs" && rm -f "libevent.so.1.0" && ln -s "libevent-2.2.so.1.0" "libevent.so.1.0")
$ grep ^library_names= libevent.la·
library_names='libevent-2.2.so.1.0 libevent.so.1.0'
# And this is wrong, it should be:
libtool: link: (cd ".libs" && rm -f "libevent-2.2.so.1" && ln -s "libevent-2.2.so.1.0.0" "libevent-2.2.so.1")
libtool: link: (cd ".libs" && rm -f "libevent.so" && ln -s "libevent-2.2.so.1.0.0" "libevent.so")
library_names='libevent-2.2.so.1.0.0 libevent-2.2.so.1 libevent.so'
**And I think that 7.1 should also fail, however it has system-wide libevent installed with evdns in the libevent.so**
Also there are some issues with `TEST_EXPORT_SHARED` test, because of libraries naming:
2022-09-13T06:38:29.2150790Z [test-export] test for install tree(in system-wide path)
2022-09-13T06:38:29.2151500Z [test-export] fail: link core and run core expects success but gets failure.
2022-09-13T06:38:29.2063870Z /usr/bin/cc CMakeFiles/test-export.dir/test-export.c.o -o test-export -L/usr/local/lib -Wl,-z,origin,-rpath,/usr/local/lib -levent_core-2.2 -lpthread -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib·
2022-09-13T06:38:29.2152190Z ld: error: unable to find library -levent_core-2.2
2022-09-13T06:38:28.3915680Z -- Install configuration: "Release"
2022-09-13T06:38:28.3916700Z -- Up-to-date: /usr/local/lib/libevent_core-2.2.so.1.0.0
2022-09-13T06:38:28.3917110Z -- Up-to-date: /usr/local/lib/libevent_core-2.2.so.1
2022-09-13T06:38:28.3917480Z -- Up-to-date: /usr/local/lib/libevent_core.so
# no libevent_core-2.2.so
So I have to disable it too.
Co-authored-by: Azat Khuzhin <azat@libevent.org>
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.
gcc 12 complains:
[34/46] Building C object CMakeFiles/event_static.dir/event.c.o
/src/le/libevent/event.c: In function ‘event_signal_closure’:
/src/le/libevent/event.c:1384:32: warning: storing the address of local variable ‘ncalls’ in ‘*ev.ev_.ev_signal.ev_pncalls’ [-Wdangling-pointer=]
1384 | ev->ev_pncalls = &ncalls;
| ~~~~~~~~~~~~~~~^~~~~~~~~
/src/le/libevent/event.c:1378:15: note: ‘ncalls’ declared here
1378 | short ncalls;
| ^~~~~~
/src/le/libevent/event.c:1378:15: note: ‘ev’ declared here
Fixes the following:
[4/38] Building C object CMakeFiles/event_shared.dir/sha1.c.o
In function ‘SHA1Update’,
inlined from ‘SHA1Final’ at /src/le/libevent/sha1.c:274:5,
inlined from ‘builtin_SHA1’ at /src/le/libevent/sha1.c:292:5:
/src/le/libevent/sha1.c:228:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 7 [-Wstringop-overread]
228 | SHA1Transform(context->state, *(const unsigned char (*)[64])&data[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/le/libevent/sha1.c:228:13: note: referencing argument 2 of type ‘const unsigned char[64]’
/src/le/libevent/sha1.c: In function ‘builtin_SHA1’:
/src/le/libevent/sha1.c:80:13: note: in a call to function ‘SHA1Transform’
80 | static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
| ^~~~~~~~~~~~~