5076 Commits

Author SHA1 Message Date
Azat Khuzhin
66428fb969 test-closed: fix -Werror=maybe-uninitialized
Follow-up for: https://github.com/libevent/libevent/pull/1680
2024-07-08 10:15:29 +02:00
Cœur
272bd7ddf0
Fix potential Null pointer dereference in test-closed.c (#1680)
* Fix potential Null pointer dereference in test-closed.c

* add err path

* code review: goto err after evutil_socketpair failure

* code review: goto err for event_config_new failure

---------

Co-authored-by: icy17 <1061499390@qq.com>
2024-07-08 10:13:08 +02:00
Cœur
49d6b4b099
samples: use evutil_socket_t instead and handle 64 bit Windows (#1682)
* Use evutil_socket_t instead in http server sample and handle 64 bit Windows

* Update http-server.c

* consistently using EV_SOCK_FMT for Windows compatibility

* code review: fix missing symbol strsignal

* Add evutil_strsignal() helper instead of strsignal() macro

---------

Co-authored-by: Hernan Martinez <hernan.c.martinez@gmail.com>
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-07-08 10:10:42 +02:00
Cœur
2bc831c889
Fix potential Null pointer dereference in test-time.c (#1681)
* Fix potential Null pointer dereference in test-time.c

* add err path

* code review: free events before base

---------

Co-authored-by: icy17 <1061499390@qq.com>
2024-07-08 10:08:58 +02:00
Azat Khuzhin
0bbaee6110 Disable persist-credentials for actions/checkout to improve security 2024-07-06 09:13:41 +02:00
Azat Khuzhin
7331c66b4d ci: limit artifacts
Refs: https://github.com/libevent/libevent/security/advisories/GHSA-f4cg-pcr2-495m
2024-07-06 09:00:38 +02:00
dependabot[bot]
7c20c21967 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.25.10 to 3.25.11
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](23acc5c183...b611370bb5)

---
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-07-01 22:51:54 +03:00
Andy Pan
96c259f1d9
tcpkeepalive: distinguish OS versions and use proper time units (#1669)
DragonFly BSD changed the time unit for TCP keep-alive from milliseconds to seconds since v5.8 and Solaris 11.4 added `TCP_KEEPIDLE`, `TCP_KEEPINTVL`, and `TCP_KEEPCNT` with time units in second while Solaris <11.4 still use `TCP_KEEPALIVE_THRESHOLD` and `TCP_KEEPALIVE_ABORT_THRESHOLD` with time units in millisecond.

Currently, we don't differentiate among DragonFly BSD versions but set the keepalive options with seconds, which will result in unexpected behaviors on DragonFlyBSD <5.8. This PR intends to fix the wrong usage of time units of TCP keepalive options on DragonFly BSD <5.8 and consolidate the logic of time units conversion for TCP keepalive across platforms.

In addition, this PR introduces a new custom macro for determining Solaris 11.4. This macro is expected to help us implement some new features for `libuv` using some abilities that only exist on Solaris 11.4 and other mainstream platforms in the future, considering that Oracle developed and released Solaris 11.4 to replenish plenty of features on Solaris that have already been implemented on other UNIX-like OSs but missing from Solaris <11.4, also bring a good deal of new features.
### References

- [Change tcp keepalive options from ms to seconds (DISRUPTIVE)](https://lists.dragonflybsd.org/pipermail/commits/2019-July/719125.html)
- [DragonFly BSD 5.8 release notes](https://www.dragonflybsd.org/release58/)
- [DragonFly TCP](https://man.dragonflybsd.org/?command=tcp&section=4)
- [Solaris 11.3 TCP](https://docs.oracle.com/cd/E86824_01/html/E54777/tcp-7p.html)
- [Solaris 11.4 TCP](https://docs.oracle.com/cd/E88353_01/html/E37851/tcp-4p.html)
- [Solaris 11.4 release notes](https://docs.oracle.com/cd/E37838_01/html/E60973/)

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-26 06:10:00 +02:00
dependabot[bot]
90b9520f3c Bump the github-actions group across 1 directory with 3 updates
Bumps the github-actions group with 3 updates in the / directory: [coverallsapp/github-action](https://github.com/coverallsapp/github-action), [ossf/scorecard-action](https://github.com/ossf/scorecard-action) and [github/codeql-action](https://github.com/github/codeql-action).


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

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

Updates `github/codeql-action` from 3.25.3 to 3.25.10
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](d39d31e687...23acc5c183)

---
updated-dependencies:
- dependency-name: coverallsapp/github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: ossf/scorecard-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-patch
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-24 10:59:28 +03:00
Cœur
78d29804db
gitignore cleanup (#1672) 2024-06-24 09:58:46 +02:00
Azat Khuzhin
e0d53cbcd5 ci: ignore lukka/run-vcpkg for updates by dependabot
Follow-up for: https://github.com/libevent/libevent/pull/1657
2024-06-24 09:47:22 +03:00
Cœur
e5181b153e
Cleanup EVENT_HAVE_ macros (#1645) 2024-06-23 21:37:49 +02:00
Cœur
8dd92069d6
Fix potential Null pointer dereference in bench_httpclient.c (#1676)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:15:23 +02:00
Cœur
5d830362dd
Fix potential Null pointer dereference in regress_dns.c (#1675)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:12:39 +02:00
Cœur
dabf4e132d
Fix potential Null pointer dereference in ws-chat-server.c (#1674)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:10:56 +02:00
Cœur
6d8c38afe7 Reducing the number of mingw warnings 2024-06-02 18:21:49 +03:00
Cœur
a0fc31bfe3 Sort symbols to check in cmake/autotools lexicographically 2024-06-02 10:25:55 +03:00
Azat Khuzhin
13678f370c
gcc: fix some compiler errors from the new GCC (#1658)
gcc: fix some compiler errors from the new GCC
2024-06-02 00:53:58 +03:00
Azat Khuzhin
3d85362557 ci: secure github.event.repository.owner.name
Even though this should not be a problem, let's do this anyway.

Reported-by: Francesco Garofalo
2024-06-01 19:57:01 +03:00
fanquake
f5b6104319 test: use evutil_timerclear over timerclear 2024-06-01 19:33:53 +03:00
Cœur
b202a72be4 temp size assert for #1632 2024-06-01 19:29:34 +03:00
Cœur
5fbc00a3cc event_warn mmap format 2024-06-01 19:29:34 +03:00
Andy Pan
fef2a8678b Fix -Wcast-function-type errors
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
e58f1fa615 Fix the -Wint-conversion
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
ee4fa05dfe Fix the compiler errors in sample/http-server.c
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
ceb6551fa2 gcc: fix the -Wincompatible-pointer-types errors
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
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