5107 Commits

Author SHA1 Message Date
Hennadii Stepanov
9a6a799e70 ci: Test Autotools build on FreeBSD 14.1
CMake builds are already tested on FreeBSD 13.4 and 14.1.
This change extends testing with Autotools to include FreeBSD 14.1.
2024-12-03 09:51:15 +03:00
dependabot[bot]
5bfb2ae81a build(deps): bump github/codeql-action in the github-actions group
Bumps the github-actions group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.27.0 to 3.27.5
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](662472033e...f09c1c0a94)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-01 19:01:18 +03:00
Azat Khuzhin
a2ed23b176 Replace deprecated find_package(PythonInterp) with Python2/Python3
Fixes: #1751
2024-11-25 10:28:59 +03:00
Azat Khuzhin
cf5571132b
Merge pull request #1752 from hebasto/241116-cmake-version
cmake: Update minimum required version
2024-11-25 01:22:24 +03:00
Hennadii Stepanov
e36398f137
cmake: Remove redundant policy settings
The `cmake_minimum_required(VERSION 3.10)` command implicitly sets the
following policies to NEW by default:
- CMP0042 (introduced in CMake 3.0)
- CMP0054 (introduced in CMake 3.1)
- CMP0068 (introduced in CMake 3.9)
2024-11-16 21:35:53 +00:00
Hennadii Stepanov
2d7a3b9b6a
cmake: Update minimum required version
Compatibility with versions of CMake older than 3.10 is now deprecated
and will be removed from a future version.

See: https://cmake.org/cmake/help/v3.31/release/3.31.html
2024-11-16 21:26:55 +00:00
Azat Khuzhin
78eb305975 Fix unlikely (for libevent) UB in HT_GROW()
The reason it is not possible for libevent is that:
a) it is unlikely to have 1610612741 elements
b) growing is done incrementally (i.e. only internally by HT_INSERT) and
   in this case the UB is not possible

Fixes: https://github.com/libevent/libevent/issues/1312
2024-11-03 00:40:17 +03:00
Kirill Rd
98b7ca30b2
http: allow passing in pre-existing connection bev (#1722)
This patch adds functionality to pass a pre-existing connection
as a bufferevent to `evhttp_connection_base_bufferevent_reuse_new`.

When the bufferevent has an existing fd, the evcon starts
in state `EVCON_IDLE` so that requests can be made immediately.

Signed-off-by: Kirill Rodriguez <theoden8@tutamail.com>
Signed-off-by: Kirill Rodriguez <theoden8@tutamail.com>
Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2024-11-02 22:39:57 +01:00
Azat Khuzhin
6b7fb78c99 Make scope of the timeval structure cleaner in event_base_loop()
Fixes: https://github.com/libevent/libevent/issues/1741
2024-11-02 22:34:24 +03:00
CXD
d6dbd7f818
Windows platform supports reading IPv6 addresses for DNS server. (#1701)
When using libevent on the Windows platform in an IPv6 environment, I found that libevent could not read the DNS server address for IPv6 addresses during DNS initialization, resulting in constant DNS resolution failures. Then, on MSDN, I discovered that the GetNetworkParams interface does not support obtaining IPv6 addresses, and they provided another interface, GetAdaptersAddresses, to obtain both IPv4 and IPv6 addresses. Therefore, I replaced the GetNetworkParams interface with the GetAdaptersAddresses interface. Please review whether this modification can be merged into the master branch.

Reference MSDN documentation:
https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getnetworkparams
https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses

Co-authored-by: alphacheng <alphacheng@tencent.com>
Co-authored-by: Azat Khuzhin <azat@libevent.org>
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2024-11-02 18:26:59 +01:00
Azat Khuzhin
ffe913b9f9
Merge pull request #1735 from theoden8/minor-improvements
various minor fixes and improvements
2024-11-02 20:04:49 +03:00
dependabot[bot]
269946b1a7 build(deps): bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [coverallsapp/github-action](https://github.com/coverallsapp/github-action) and [github/codeql-action](https://github.com/github/codeql-action).


Updates `coverallsapp/github-action` from 2.3.0 to 2.3.4
- [Release notes](https://github.com/coverallsapp/github-action/releases)
- [Commits](643bc377ff...cfd0633edb)

Updates `github/codeql-action` from 3.26.6 to 3.27.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4dd16135b6...662472033e)

---
updated-dependencies:
- dependency-name: coverallsapp/github-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-02 19:54:15 +03:00
Kirill Rodriguez
cdef74fdff
remove old issue reference
Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
2024-11-01 00:10:57 +00:00
Kirill Rodriguez
23839cb096
mm_strdup instead of strdup
Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
2024-11-01 00:25:02 +00:00
Azat Khuzhin
6313a61d50
Ignore Proxy-Connection in request header (#1736)
* don't strip Proxy-Connection
* remove Proxy-Connection
* remove proxy-connection from http-connect
* moved EVHTTP_ flags to http.c
* fix flags definition placements in http.c
* fix unused variable

Co-authored-by: Greg Hazel <ghazel@gmail.com>
2024-11-01 01:37:19 +03:00
Azat Khuzhin
3c8d89b9b2
Merge pull request #1737 from libevent/signal-tests
Retry tests with SIGALRM on OSX (and fix some related stuff)
2024-11-01 01:30:58 +03:00
Kirill Rodriguez
6f35d4dfe8
probably platform caching at work too, let's make different nodenames
Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
2024-10-31 14:52:44 +00:00
Kirill Rodriguez
d2facdae42
hitting cache makes cancel stress test unreliable
Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
2024-10-31 10:18:22 +00:00
Kirill Rodriguez
e219dd4a6e
return EAI_ADDRFAMILY instead of NULL (propagate to caller)
Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
2024-11-02 00:53:31 +00:00
Kirill Rodriguez
e9559cd173
fix unused variable 2024-10-29 15:20:08 +00:00
Kirill Rodriguez
c35d406d10
fix flags definition placements in http.c 2024-10-29 11:43:02 +00:00
Kirill Rodriguez
a92ce7e111
moved EVHTTP_ flags to http.c 2024-10-29 11:26:35 +00:00
Kirill Rodriguez
a8cd11f90f
remove proxy-connection from http-connect 2024-10-29 11:18:48 +00:00
Azat Khuzhin
f01879d5a6 Align ELF sections to 16K boundaries (-Wl,-z,max-page-size=16384)
Even though the initial request was about Android, it is not only about
it, but it could be the case for Linux as well (so as Apple M1/...
chips)

And this should not affect anything, since this is just ELFs

Fixes: https://github.com/libevent/libevent/issues/1708
2024-10-29 11:41:26 +03:00
Azat Khuzhin
25fa9c7732 test: retry signal tests with SIGALRM no OSX
By some reason even after first ALRM signal received and event loop
returned it is possible to recieve an ALRM one more time (at least one):

    % yes signal/simple_signal.. | head -n 1000 | xargs -I{} -P10 sh -c 'EVENT_DEBUG_LOGGING_ALL= bin/regress --timeout 0 --verbose {} >& /tmp/test.$SECONDS.$RANDOM.log'
    % cat /tmp/test.0.18384.log
    signal/simple_signal: [forking] [debug] event_add: event: 0x16d70f368 (fd 14),     call 0x102704ae8
    [debug] evsig_ensure_saved_: evsignal (14) >= sh_old_max (0), resizing

             OK /Users/ec2-user/libevent/test/regress.c:1086: assert(setitimer(ITIMER_REAL, &itv, NULL) == 0): 0 vs 0[debug] kq_dispatch: kevent reports 1
    [debug] event_active: 0x16d70f368 (fd 14), res 8, callback 0x102704ae8
    [debug] event_process_active: event: 0x16d70f368,    call 0x102704ae8
    [debug] event_del: 0x16d70f368 (fd 14), callback 0x102704ae8
    [debug] event_base_loop: no events registered.

      FAIL /Users/ec2-user/libevent/test/regress.c:1062: ALRM received not from event loop![debug] event_del: 0x16d70f368 (fd 14), callback 0x102704ae8
    [debug] event_base_free_: 0 events freed
    signal/simple_signal: exited with 0 (0)

      [FAILED signal/simple_signal (0 retries)]
    signal/simple_signal_re_order: [forking] [debug] event_add: event: 0x16d70f368 (fd 14),     call 0x102704ae8
    [debug] evsig_ensure_saved_: evsignal (14) >= sh_old_max (0), resizing
    [debug] event_del: 0x16d70f368 (fd 14), callback 0x102704ae8
    [debug] event_add: event: 0x16d70f368 (fd 14),     call 0x102704ae8

             OK /Users/ec2-user/libevent/test/regress.c:1086: assert(setitimer(ITIMER_REAL, &itv, NULL) == 0): 0 vs 0[debug] kq_dispatch: kevent reports 1
    [debug] event_active: 0x16d70f368 (fd 14), res 8, callback 0x102704ae8
    [debug] event_process_active: event: 0x16d70f368,    call 0x102704ae8
    [debug] event_del: 0x16d70f368 (fd 14), callback 0x102704ae8
    [debug] event_base_loop: no events registered.
    [debug] event_del: 0x16d70f368 (fd 14), callback 0x102704ae8
    [debug] event_base_free_: 0 events freed
    signal/simple_signal_re_order: exited with 0 (0)

    1/2 TESTS FAILED. (0 skipped)

Also note, that the problem not only when I run two tests, but only one
as well:

    % bin/regress --timeout 0 --repeat 1000 --verbose --no-fork signal/simple_signal >/tmp/test2.log 2>&1
    signal/simple_signal:
             OK /Users/ec2-user/libevent/test/regress.c:1086: assert(setitimer(ITIMER_REAL, &itv, NULL) == 0): 0 vs 0
    signal/simple_signal:
             OK /Users/ec2-user/libevent/test/regress.c:1086: assert(setitimer(ITIMER_REAL, &itv, NULL) == 0): 0 vs 0
      FAIL /Users/ec2-user/libevent/test/regress.c:1062: ALRM received not from event loop!

I've tried to run under "ktrace trace -Ss -f C4,S0x010c -c" but of
course it does not fails under it (dtruss by some reason did not work
for me).

P.S. Also remove one TT_RETRIABLE for one test, since only setitimer()
causes this.
2024-10-29 09:28:53 +01:00
Azat Khuzhin
29a3eee5ca test: add --repeat option into tinytest 2024-10-29 09:28:53 +01:00
Azat Khuzhin
7b14bc16f2 test: add fallback for SIGALRM 2024-10-29 09:28:53 +01:00
Azat Khuzhin
c94b382577 test: do not ignore setitimer() failures 2024-10-29 09:28:53 +01:00
Azat Khuzhin
ca163ff1e1 test: fix retries of signal tests on apple 2024-10-29 09:28:53 +01:00
Azat Khuzhin
5e427ad98b test: rename signal tests (simple_signal and simple_signal_re_order) 2024-10-29 09:28:53 +01:00
David Goulet
f84896d37f
dns: Return DNS query type on error (#1220)
When calling the user callback after a DNS resolution on error, make
sure to send back the query type (A, AAAA, PTR).

Closes #1219

Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-10-28 21:50:29 +01:00
Azat Khuzhin
342a0faa50 Avoid loosing previously active events in case of EV_TIMEOUT
Previously all the existing events was lost if the timeout had been
triggered on that event.

Fixes: #1530
2024-10-28 23:46:18 +03:00
Andy Pan
528fbed184 kqueue: make changelist and eventlist of kevent share the same array
The array used by the changelist of the kevent() can be reused by the eventlist,
We should make use of this feature to eliminate the extra overhead of array allocation.

https://man.freebsd.org/cgi/man.cgi?kqueue
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html
https://leaf.dragonflybsd.org/cgi/web-man?command=kqueue&section=2
https://man.netbsd.org/kqueue.2
https://man.openbsd.org/kqueue.2

---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-10-28 09:15:57 +03:00
Loganaden Velvindron
afb7f48344
arc4: drop 4096 bytes of the early keystream (#1586)
It might be safer to drop 4096 bytes to be on the safe side.

See: twitter.com/nugxperience/status/1773906926503591970
2024-10-27 17:30:44 +01:00
Cœur
ba0442bacc Improve hashsocket() (for win32) to avoid collisions
Fixes: 91e3ead
Refs: https://gist.github.com/azat/8a0a94e4de2d95af8f729b709589ce12
2024-10-27 15:55:12 +01:00
Cœur
b456e4bd82
Use arc4random_stir over deprecated arc4random_addrandom (#1631)
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-10-26 20:46:41 +02:00
Kirill Rd
e30b215f34
Add caching for evdns (#1717)
No evdns will do caching by default (with respect to TTL), to disable this set EVDNS_BASE_NO_CACHE

There are also helpers for manually manage the cache:
- evdns_cache_write()
- evdns_cache_lookup()

Initial PR: #571
Fixes: #1715

Co-authored-by: Greg Hazel <ghazel@gmail.com>
Co-authored-by: Keith Moore <kmoore@clostra.com>
2024-10-24 08:28:53 +02:00
James
267e808eb7
Updated documentation for bufferevent_setcb() (#1733)
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2024-10-23 22:54:31 +02:00
Azat Khuzhin
2a1ec766ed ci/openbsd: bump autoconf version to 2.72 2024-10-21 21:54:19 +02:00
Azat Khuzhin
b219226982 Fix notifying the base in a different thread after removing active timer event
The base should be notified in case of timer removal if that was the
minimal timer in the base.

Reported-by: @moihn (who is also provided the reproducer on which this
test is based on)
Fixes: https://github.com/libevent/libevent/issues/1727
2024-10-21 09:02:56 +02:00
Azat Khuzhin
970a258bc6
CI and tests fixes (#1719) 2024-10-21 10:02:33 +03:00
Azat Khuzhin
468be957cd
tests: add a test for event_free() from signal callback handler (#1729) 2024-10-21 09:58:38 +03:00
Kirill Rodriguez
ae635d4b5b
add explicit check for linux 2024-10-20 21:47:17 +01:00
Kirill Rodriguez
c923a184c6
getaddrinfo with localhost does not necessarily read files 2024-10-20 21:43:09 +01:00
Kirill Rodriguez
096c5fe584
update openbsd pkg names to 7.6 2024-10-20 21:43:09 +01:00
Kirill Rodriguez
5755befda6
fix a Werror error 2024-10-20 21:43:05 +01:00
Kirill Rodriguez
370d99244d
mbedtls3 does not support tls<1.3, and tls<1.3 does not support renegotiations. therefore, disable 2024-10-20 21:41:36 +01:00
Kirill Rodriguez
87c921f9fc
make sure cmake cache misses when configuration files change 2024-10-20 21:41:26 +01:00
Azat Khuzhin
dc37edc4ea Add a comment about handling event_free() for signals in event_signal_closure() 2024-10-20 21:59:13 +02:00
Azat Khuzhin
77fed76099 tests: add a test for event_free() from callback handler for signals
Refs: https://github.com/libevent/libevent/issues/1287
2024-10-20 21:57:02 +02:00