5107 Commits

Author SHA1 Message Date
Cœur
9e89a40748 Fix Windows format warning in newer Visual Studio 2024-06-01 19:20:10 +03:00
Hennadii Stepanov
525f5d0a14 ci: Switch lukka/run-vcpkg back to v7
Newer versions expect a vcpkg manifest.
2024-05-20 17:17:27 +03:00
Azat Khuzhin
ab338ab1dc ci: fix typo in matrix 2024-05-20 11:19:28 +02:00
Andy Pan
7a9458c09b
Don't try to set SO_REUSEADDR and SO_REUSEPORT on Unix sockets (#1625) 2024-05-20 11:17:45 +02:00
Cœur
66ee086bf1 Fix conversion loses precision ssize_t to int in evthread_notify_base_default() 2024-05-18 16:18:54 +02:00
Cœur
7afbdcf25e Ensure that event had been removed in event_process_active_single_queue()
It should not be possible, since only EVLIST_ACTIVE should be triggered
from event_process_active_single_queue, but adding assert will not hurt.
2024-05-18 16:17:55 +02:00
Andy Pan
8976100a44 unix: fail the operation when SO_REUSEPORT has no load balancing
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-18 16:58:50 +03:00
Andy Pan
832f52692e aix: enable SO_REUSEPORT on AIX
AIX 7.2.5 added the feature that would add the capability
to distribute incoming connections across all listening ports.

https://www.ibm.com/support/pages/how-get-better-listening-performance-multiple-listening-sockets-using-same-port-number-soreuseport

---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-18 16:57:54 +03:00
Andy Pan
a41453ab51 Eliminate the redundant ev_uint64_t for eventfd
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-05-18 16:53:37 +03:00
Azat Khuzhin
fc9bfd210d
Merge pull request #1649 from azat/be/BSD-connect-failures
Fix tests failures due to incorrect handling of ECONNREFUSED on BSD
2024-05-07 22:15:40 +03:00
Cœur
6d125f5486
Fix evbuffer_file_segment_new 64-bit support on Win32 (#1637)
This fixes the problematic #define fstat _fstat which would only support files up to 2 GB.

Also refactored it as evutil_fd_filesize to avoid exposing stat when not necessary.
2024-05-06 09:28:48 +02:00
Cœur
af31823fb2 Fix potential Null pointer dereference in bufferevent_openssl.c 2024-05-06 10:23:45 +03:00
Azat Khuzhin
85a0ec9b2d be: make the code in bufferevent_socket_connect() more reliable
There is one icky in case for windows:

        if (sa) {
 #ifdef _WIN32
                if (bufferevent_async_can_connect_(bev)) {
                        bufferevent_setfd(bev, fd);
                        r = bufferevent_async_connect_(bev, fd, sa, socklen);
                        if (r < 0)
                                goto freesock;
                        bufev_p->connecting = 1;
                        result = 0;
                        goto done;
-               } else
+               } else {
 #endif
                r = evutil_socket_connect_(&fd, sa, socklen);
                if (r < 0) // Previosly this line was executed
                           // regardless of bufferevent_async_can_connect_(), but the case under
                           // bufferevent_async_can_connect_() always does goto, so it is 100% the
                           // same code, but just to make it more cleaner
                        goto freesock;
+#ifdef _WIN32
+               }
+#endif
        }
2024-05-06 09:13:45 +02:00
Azat Khuzhin
3201009b3f Revert "Remove dead code from bufferevent_socket_connect"
That wasn't the dead code, since the `r` could be `2` in case of
`ECONNREFUSED`, and it should trigger errorcb not the writecb.

This is actually questionable should be call errorcb at all in case of
connect() returns an error immediately, but I guess the reason was to
make it compatible with others, ECONNREFUSED can be returned only for
specific cases and only on BSD (AFAIK). While for instance EHOSTUNREACH
is not.

And after this change now all tests are passed on FreeBSD. Well,
sometimes few tests fails due to timing issues, but in general looks
good. Since even all tests in parallel passed:

    $ rm -f /tmp/libevent*log; bin/regress --list-tests | awk '/^    / { print $1 }' | xargs -I{} -P100 bash -c 'n={}; bin/regress --no-fork --verbose $n |& tee /tmp/libevent-test-${n//\//_}.log' |& grep -F '  [FAILED' |& tee /tmp/libevent-tests.log

And having green CI is crucial for libevent, not only because it is
a rule of thumb for all projects, but also because in case of failures
it will retry on and on, which will cause CI stuck.

Fixes: bufferevent/bufferevent_connect_fail
Fixes: bufferevent/bufferevent_connect_fail_eventcb
Fixes: bufferevent/bufferevent_connect_fail_eventcb_defer

This reverts commit 56e121310954cbee2310c5eb2a3000115186563d.
Refs: https://github.com/libevent/libevent/pull/1100
2024-05-06 09:13:45 +02:00
Azat Khuzhin
3f7c1cba5b be: add a comment for handling ECONNREFUSED in bufferevent_readcb()
Fixes: 3189eb000b6d8751223061930a019f85c284f985 ("be_sock: handle readv() returns ECONNREFUSED (freebsd 9.2)")
2024-05-06 09:13:45 +02:00
Azat Khuzhin
c6a74ee04f Merge branch 'test/fixes' -- more small fixes
* test/fixes:
  test: mark http/timeout_read_server as retriable
  test: reset some static vars to avoid affecting other tests
  test: fix printing number of retries for FAILED message
  test: add debugging for bufferevent/bufferevent_connect_fail_eventcb*
  test: suppress logging for buffer/add_file_leak1
2024-05-06 09:13:21 +02:00
Azat Khuzhin
0f51ba669a test: mark http/timeout_read_server as retriable 2024-05-06 09:13:00 +02:00
Azat Khuzhin
ba97d94738 test: reset some static vars to avoid affecting other tests 2024-05-06 09:13:00 +02:00
Azat Khuzhin
479b5ed6f4 test: fix printing number of retries for FAILED message 2024-05-06 09:13:00 +02:00
Azat Khuzhin
d538f41f0a test: add debugging for bufferevent/bufferevent_connect_fail_eventcb* 2024-05-06 09:13:00 +02:00
Azat Khuzhin
2d4d1747e9 test: suppress logging for buffer/add_file_leak1
Warnings from this test should be ignored:

    [warn] evbuffer_file_segment_materialize: mmap(5, 0, 0) failed: Invalid argument
2024-05-06 09:13:00 +02:00
Azat Khuzhin
6bb41ed0bb Merge branch 'test/fix-reports'
* test/fix-reports:
  test: add proper message in case of test failure
  test: fix RETRYING message (add missing group prefix)
2024-05-05 20:22:43 +02:00
Azat Khuzhin
93a76aa275 test: add proper message in case of test failure
Right now it is impossible to understand what had been failed, but
after:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 1, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 0, delay 1 sec)]
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [conditions_simple FAILED]

      [FAILED thread/conditions_simple (attempts made -1)]
    1/1 TESTS FAILED. (0 skipped)
2024-05-05 20:22:23 +02:00
Azat Khuzhin
d5745413cc test: fix RETRYING message (add missing group prefix)
Before:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING conditions_simple (attempts left 2, delay 1 sec)]

After:

    $ regress thread/conditions_simple
    thread/conditions_simple: [forking]
      FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
      [RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
2024-05-05 20:21:58 +02:00
Cœur
5d45f4d9ff Simplifying apple-cmake-job 2024-05-05 09:34:14 +03:00
Azat Khuzhin
ccf4c74d39 Add ChangeLog-2.1/ChangeLog (aka 2.2) into dist package 2024-05-05 09:33:17 +03:00
Cœur
d241fcabd6 Add Privacy Manifest for App Store submissions
Doc: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
From the API list, the libevent library only uses:
- mach_absolute_time, but that one is avoided with HAVE_POSIX_MONOTONIC (default) instead of HAVE_MACH_MONOTONIC
- fstat and stat in evbuffer_file_segment_new, which is covered by third-party SDK usage (0A2A.1)
- fstat and stat in evutil_read_file_, which is used to read the "/etc/resolv.conf" and "/etc/hosts" files, for which there are no available supporting reasons
2024-05-05 09:32:37 +03:00
Cœur
7ede5af692
Updating deprecated GitHub actions (#1629)
* Updating deprecated GitHub actions

* code review: use commit hash for actions
2024-05-04 12:04:14 +02:00
dependabot[bot]
ac96656c2f 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.24.10 to 3.25.3
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4355270be1...d39d31e687)

---
updated-dependencies:
- 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-05-04 12:52:27 +03:00
Azat Khuzhin
534da76d44
Merge pull request #1641 from Coeur/coeur/apple-cmake-job
Adding apple-cmake-job for an iOS/tvOS/visionOS/watchOS build
2024-05-04 12:48:57 +03:00
Cœur
f516e399b4
Fix brew path on Apple Silicon (#1633)
* Fix brew path on Apple Silicon

* code review: `brew --prefix openssl`

* code review: correct mbedtls path

* code review: cmake does support autodetection of OPENSSL_ROOT_DIR
2024-05-04 11:42:26 +02:00
Cœur
3c744ceed0 fix linux retrying cmake 2024-05-04 12:41:00 +03:00
hunterx008
0428771acb Remove redundant condition in function:event_base_once 2024-05-04 12:39:38 +03:00
Cœur
71108830f6 using xcode-version: latest-stable for xros support 2024-05-02 13:16:04 +08:00
Cœur
b7fb04e88e Adding apple-cmake-job for an iOS/tvOS/watchOS build 2024-05-02 12:57:55 +08:00
Cœur
eec47a6710
Fix typos (#1634) 2024-04-30 09:59:58 +02:00
icy17
64decd48e2
Fix potential Null pointer dereference in dns-example.c (#1601) 2024-04-29 07:51:22 +02:00
icy17
a584efaa0e Fix potential Null pointer dereference in time-test.c 2024-04-29 08:47:25 +03:00
Andy Pan
aef201a9fc
Change ident for EVFILT_USER to 0 and add a test (#1582)
Conventionally, ident for EVFILT_USER is set to 0 to avoid
collision of file descriptors, which is what other renowned
networking frameworks like netty(java), mio(rust), gnet(go),
swift-nio(swift), etc. do currently.

Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-04-29 07:35:33 +02:00
Andy Pan
cbbf209c08
Support SO_REUSEPORT on FreeBSD, DragonFly and Solaris (#1624)
## References

- [The SO_REUSEPORT socket option on Linux](https://lwn.net/Articles/542629/)
- [DragonFly Release 3.6](https://www.dragonflybsd.org/release36/)
- [FreeBSD 12.0-RELEASE Release Notes](https://www.freebsd.org/releases/12.0R/relnotes/)
- [SO_REUSEPORT on Solaris 11.4](https://docs.oracle.com/cd/E88353_01/html/E37843/setsockopt-3c.html)

Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-04-29 07:31:34 +02:00
Cœur
a942694155 Fix CMake Deprecation Warning 2024-04-29 08:17:43 +03:00
Cœur
73c0349ed4
Fix evutil_parse_sockaddr_port documentation (#1628)
In some IDE like Xcode, the list is interpreted as markdown instead of plain text
2024-04-29 07:16:58 +02:00
Hennadii Stepanov
71d41cdf37 build: Add Iphlpapi to Libs.private in *.pc files on Windows
It has been required since https://github.com/libevent/libevent/pull/923
at least for the `if_nametoindex` call.
2024-04-25 09:44:01 +02:00
Emil Engler
1e6c0e726b Do not set TCP keepalive on Unix sockets
This commit disables the property of TCP keepalive on Unix domain
sockets, because they essentially serve no purpose here, except for
causing problems on Windows and macOS systems.

Fixes #1615
2024-04-24 09:28:32 +02:00
dockercui
147298a2d1 Fix some comments
Signed-off-by: dockercui <dockercui@aliyun.com>
2024-04-24 08:27:12 +02:00
Andy Pan
6074d55822 Avoid calling read(2) on eventfd on each event-loop wakeup
Register the eventfd with EPOLLET to enable edge-triggered notification
where we don't need to read the data from the eventfd for every wakeup
event.

When the eventfd counter reaches the maximum value of the unsigned 64-bit,
we rewind the counter and retry again. This optimization saves one system
call on each event-loop wakeup, which eliminates the extra latency for epoll
as the EVFILT_USER filter does for the kqueue.
2024-04-20 13:16:17 +03:00
dependabot[bot]
e0a4574ba2 Bump the github-actions group with 5 updates
Bumps the github-actions group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [actions/cache](https://github.com/actions/cache) | `3` | `4` |
| [nick-fields/retry](https://github.com/nick-fields/retry) | `2` | `3` |
| [coverallsapp/github-action](https://github.com/coverallsapp/github-action) | `1.2.5` | `2.2.3` |
| [ossf/scorecard-action](https://github.com/ossf/scorecard-action) | `2.1.2` | `2.3.1` |
| [github/codeql-action](https://github.com/github/codeql-action) | `2.2.4` | `3.24.10` |


Updates `actions/cache` from 3 to 4
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

Updates `nick-fields/retry` from 2 to 3
- [Release notes](https://github.com/nick-fields/retry/releases)
- [Changelog](https://github.com/nick-fields/retry/blob/master/.releaserc.js)
- [Commits](https://github.com/nick-fields/retry/compare/v2...v3)

Updates `coverallsapp/github-action` from 1.2.5 to 2.2.3
- [Release notes](https://github.com/coverallsapp/github-action/releases)
- [Upgrade guide](https://github.com/coverallsapp/github-action/blob/main/UPGRADE.md)
- [Commits](09b709cf6a...3dfc556739)

Updates `ossf/scorecard-action` from 2.1.2 to 2.3.1
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](e38b1902ae...0864cf1902)

Updates `github/codeql-action` from 2.2.4 to 3.24.10
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](17573ee1cc...4355270be1)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: nick-fields/retry
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: coverallsapp/github-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 09:39:14 +03:00
Diogo Teles Sant'Anna
80e25c02ff Enable dependabot for github actions 2024-04-15 10:40:35 +03:00
Diogo Teles Sant'Anna
a4ec4cbe51 Hashpin workflows that use sensitive permisisons 2024-04-15 10:40:35 +03:00
williammuji
9de85b5834 fix WSOptions enum value and extended payload length bug 2024-04-15 10:31:04 +03:00