]> granicus.if.org Git - libevent/log
libevent
2 years agobuild: use modern ax_pthread macro
fanquake [Wed, 24 Nov 2021 00:44:03 +0000 (08:44 +0800)]
build: use modern ax_pthread macro

acx_pthread became ax_pthread in 2009 and the macro has seen lots of updates
since then. This change switches to using the latest version.

2 years agoRevert "evdns: do not check server_req twice"
Azat Khuzhin [Tue, 30 Nov 2021 19:41:05 +0000 (22:41 +0300)]
Revert "evdns: do not check server_req twice"

That was wrong assumption.

This reverts commit 991f0ed3d86ffca0c017ab83cd239289912bdaad.

Fixes: #1231
2 years agoci: remove deprecated windows-2016 image
Azat Khuzhin [Tue, 30 Nov 2021 19:37:32 +0000 (22:37 +0300)]
ci: remove deprecated windows-2016 image

Refs: https://github.blog/changelog/2021-10-19-github-actions-the-windows-2016-runner-image-will-be-removed-from-github-hosted-runners-on-march-15-2022

2 years agoDon't define BIO_get_init() for LibreSSL 3.5+
Theo Buehler [Sun, 21 Nov 2021 20:38:20 +0000 (21:38 +0100)]
Don't define BIO_get_init() for LibreSSL 3.5+

BIO_get_init() is available in LibreSSL 3.5 and later. The BIO type
will become opaque, so the existing macro will break the build.

2 years agoMerge #1230 -- build: remove inconsistently used x-prefix comparisons
Azat Khuzhin [Tue, 30 Nov 2021 19:22:43 +0000 (22:22 +0300)]
Merge #1230 -- build: remove inconsistently used x-prefix comparisons

* upstream/pr/1230:
  build: fix typos in ax_check_funcs_ex.m4
  build: remove inconsistently used x-prefix comparisons

2 years agobuild: fix typos in ax_check_funcs_ex.m4
fanquake [Wed, 24 Nov 2021 06:44:48 +0000 (14:44 +0800)]
build: fix typos in ax_check_funcs_ex.m4

2 years agobuild: remove inconsistently used x-prefix comparisons
fanquake [Wed, 24 Nov 2021 06:41:33 +0000 (14:41 +0800)]
build: remove inconsistently used x-prefix comparisons

Given that these are already used inconsistently with `test` checks, it
makes sense to consolidate to not use the x-prefix comparisons at all.
In any case, it would be nice to think we no longer have to work around
a problem that existed in shells many, many years ago.

More info:
https://github.com/koalaman/shellcheck/wiki/SC2268
https://www.vidarholen.net/contents/blog/?p=1035

2 years agoFix comment for evdns_base_new()
Azat Khuzhin [Sun, 21 Nov 2021 21:05:27 +0000 (00:05 +0300)]
Fix comment for evdns_base_new()

2 years agoCheckWorkingKqueue.cmake: fix missing headers
Christopher Chavez [Fri, 12 Nov 2021 02:12:14 +0000 (20:12 -0600)]
CheckWorkingKqueue.cmake: fix missing headers

Avoid implicitly declaring functions memset() and exit()
as it is considered an error by some compilers
(e.g. Xcode clang 12 and later)

2 years agoevutil: Fix evutil_freeaddrinfo
Tomas Gonzalez [Mon, 1 Nov 2021 17:01:06 +0000 (10:01 -0700)]
evutil: Fix evutil_freeaddrinfo

During testing on win32, util/getaddrinfo failed with NULL hint info

     r = evutil_getaddrinfo("www.google.com", NULL, NULL, &ai);

throwing a critical heap exception when evutil_freeaddrinfo is called.
This is because of improper use of freeaddrinfo when nodes within the
ai structure are allocated using mm_malloc or mm_calloc
(EVUTIL_AI_LIBEVENT_ALLOCATED)

This adds the flag in apply_socktype_protocol_hack and walks the linked
list in evutil_freeaddrinfo removing linked list nodes that are custom
allocated before calling freeaddrinfo.

2 years agotest: retriable tests are marked failed only when all attempts have failed
Thomas Perrot [Wed, 29 Sep 2021 11:50:35 +0000 (13:50 +0200)]
test: retriable tests are marked failed only when all attempts have failed

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
3 years agogithub/workflows/macos.yml: fix test step name
Azat Khuzhin [Sun, 19 Sep 2021 12:52:02 +0000 (15:52 +0300)]
github/workflows/macos.yml: fix test step name

3 years agoMerge branch 'skip-tests' -- fix/skip some tests to avoid complete check failures
Azat Khuzhin [Sun, 19 Sep 2021 12:59:57 +0000 (15:59 +0300)]
Merge branch 'skip-tests' -- fix/skip some tests to avoid complete check failures

* skip-tests:
  test: add --retries-delay (and set to 1 second by default)
  test: add --retries argument
  Add -Wno-void-pointer-to-enum-cast (we use this hack in tests)
  test/regress_http: mark data_length_constraints as retriable
  github/workflows/mingw: use ctest --output-on-failure
  test/dns: mark TCP tests as retriable
  test/regress: retry some signal rlated tests in darwin
  test/regress_util: mark monotonic_prc as retriable
  test/regress_http: fix unix_socket test
  test/regress_http: disable max_connections/data_length_constraints under windows
  Add EV_WINDOWS macro

3 years agotest: add --retries-delay (and set to 1 second by default)
Azat Khuzhin [Sun, 19 Sep 2021 10:18:40 +0000 (13:18 +0300)]
test: add --retries-delay (and set to 1 second by default)

In attemp to address failures of dns/tcp_* tests under windows [1].

  [1]: https://github.com/azat/libevent/runs/3644218468?check_suite_focus=true

3 years agotest: add --retries argument
Azat Khuzhin [Sun, 19 Sep 2021 10:15:02 +0000 (13:15 +0300)]
test: add --retries argument

3 years agoAdd -Wno-void-pointer-to-enum-cast (we use this hack in tests)
Azat Khuzhin [Sun, 19 Sep 2021 10:36:15 +0000 (13:36 +0300)]
Add -Wno-void-pointer-to-enum-cast (we use this hack in tests)

Refs: https://reviews.llvm.org/D75758

3 years agotest/regress_http: mark data_length_constraints as retriable
Azat Khuzhin [Sun, 19 Sep 2021 09:56:24 +0000 (12:56 +0300)]
test/regress_http: mark data_length_constraints as retriable

CI: https://github.com/libevent/libevent/runs/3643914024?check_suite_focus=true

3 years agogithub/workflows/mingw: use ctest --output-on-failure
Azat Khuzhin [Sun, 19 Sep 2021 09:33:44 +0000 (12:33 +0300)]
github/workflows/mingw: use ctest --output-on-failure

Otherwise it is hard to understand the problem [1].

  [1]: https://github.com/azat/libevent/runs/3643912284

3 years agotest/dns: mark TCP tests as retriable
Azat Khuzhin [Sun, 19 Sep 2021 09:24:50 +0000 (12:24 +0300)]
test/dns: mark TCP tests as retriable

CI: https://github.com/azat/libevent/runs/3643912296 # tcp_resolve_many_clients
CI: https://github.com/azat/libevent/runs/3643912192 # tcp_timeout
CI: https://github.com/azat/libevent/runs/3643912336 # tcp_resolve
CI: https://github.com/azat/libevent/runs/3643912174 # tcp_resolve_pipeline

3 years agotest/regress: retry some signal rlated tests in darwin
Azat Khuzhin [Sun, 19 Sep 2021 09:23:48 +0000 (12:23 +0300)]
test/regress: retry some signal rlated tests in darwin

CI: https://github.com/azat/libevent/runs/3643912290 # simplestsignal
CI: https://github.com/azat/libevent/runs/3643912296 # simplesignal
CI: https://github.com/azat/libevent/runs/3643912228 # multiplesignal

3 years agotest/regress_util: mark monotonic_prc as retriable
Azat Khuzhin [Sun, 19 Sep 2021 09:21:39 +0000 (12:21 +0300)]
test/regress_util: mark monotonic_prc as retriable

CI: https://github.com/azat/libevent/runs/3643966877

3 years agotest/regress_http: fix unix_socket test
Azat Khuzhin [Sun, 19 Sep 2021 08:07:55 +0000 (11:07 +0300)]
test/regress_http: fix unix_socket test

3 years agotest/regress_http: disable max_connections/data_length_constraints under windows
Azat Khuzhin [Sun, 19 Sep 2021 07:54:27 +0000 (10:54 +0300)]
test/regress_http: disable max_connections/data_length_constraints under windows

CI: https://github.com/libevent/libevent/runs/3643554394

3 years agoAdd EV_WINDOWS macro
Azat Khuzhin [Sun, 19 Sep 2021 07:54:08 +0000 (10:54 +0300)]
Add EV_WINDOWS macro

3 years agoci: split build and test into separate jobs
Azat Khuzhin [Tue, 10 Aug 2021 19:04:43 +0000 (22:04 +0300)]
ci: split build and test into separate jobs

3 years agotest: cleanup stalled socket after running http/unix_sock
Azat Khuzhin [Sat, 18 Sep 2021 22:47:42 +0000 (01:47 +0300)]
test: cleanup stalled socket after running http/unix_sock

Otherwise it breaks upload-artifacts:

    Run actions/upload-artifact@v1
    Uploading artifact 'ubuntu-18.04-cmake-NONE-build' from '/home/runner/work/libevent/libevent/build' for run #346
    Uploading 1095 files
    File error 'No such device or address' when uploading file '/home/runner/work/libevent/libevent/build/foo'.
    ...
    Error: No such device or address
    Error: Exit code 1 returned from process: file name '/home/runner/runners/2.282.1/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

3 years agotest: check return value of write()/send() in bufferevent_read_failed
Azat Khuzhin [Sat, 18 Sep 2021 22:23:07 +0000 (01:23 +0300)]
test: check return value of write()/send() in bufferevent_read_failed

This will also suppress:

    ../test/regress_bufferevent.c: In function ‘test_bufferevent_read_failed’: 1102
    ../test/regress_bufferevent.c:1395:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 1103
      write(data->pair[0], buf, strlen(buf));

3 years agotest: mark util/monotonic_prc_fallback as retriable
Azat Khuzhin [Sat, 18 Sep 2021 21:57:31 +0000 (00:57 +0300)]
test: mark util/monotonic_prc_fallback as retriable

Refs: #1193

3 years agobufferevent_ssl: check return value of the evbuffer_drain()
Azat Khuzhin [Sat, 18 Sep 2021 21:39:30 +0000 (00:39 +0300)]
bufferevent_ssl: check return value of the evbuffer_drain()

Refs: #1163

3 years agoMerge remote-tracking branch 'upstream/pr/1203'
Azat Khuzhin [Sat, 18 Sep 2021 21:27:53 +0000 (00:27 +0300)]
Merge remote-tracking branch 'upstream/pr/1203'

@ploxiln:

  "It seems like a bit of refactoring might be able to clean this code
up a bit, but it's a bit tricky because of the varied tricky usage of
chain structs, so this initial version has minimal changes ... "

* upstream/pr/1203:
  buffer: do not round up allocation for reference-type chain objects

3 years agoMerge !1204 -- tests: fix macOS CI runs
Azat Khuzhin [Sat, 18 Sep 2021 21:23:10 +0000 (00:23 +0300)]
Merge !1204 -- tests: fix macOS CI runs

* upstream/pr/1204:
  test: http_unix_socket_test: fix url could be freed uninitialized
  test: regress_http: skip unix socket parsing tests in windows
  test: fix regress_http evhttp_bind_unixsocket() on macOS
  ci: fix macOS mbedtls version/search

3 years agotest: http_unix_socket_test: fix url could be freed uninitialized
Pierce Lopez [Fri, 17 Sep 2021 08:47:34 +0000 (04:47 -0400)]
test: http_unix_socket_test: fix url could be freed uninitialized

> regress_http.c:2279:2: warning: variable 'uri' is used uninitialized
>     whenever 'if' condition is true

3 years agotest: regress_http: skip unix socket parsing tests in windows
Pierce Lopez [Fri, 17 Sep 2021 05:56:56 +0000 (01:56 -0400)]
test: regress_http: skip unix socket parsing tests in windows

windows doesn't do unix sockets

3 years agotest: fix regress_http evhttp_bind_unixsocket() on macOS
Pierce Lopez [Fri, 17 Sep 2021 05:39:46 +0000 (01:39 -0400)]
test: fix regress_http evhttp_bind_unixsocket() on macOS

needs to use evutil socket helper for SOCK_NONBLOCK / SOCK_CLOEXEC

3 years agoci: fix macOS mbedtls version/search
Pierce Lopez [Fri, 17 Sep 2021 05:37:19 +0000 (01:37 -0400)]
ci: fix macOS mbedtls version/search

mbedtls just updated to version 3.0, install mbedtls@2 variant,
which needs more help being located since it's no longer the
default and no longer linked into the typical /usr/local dirs

also gitignore mbedtls sample program binaries

3 years agobuffer: do not round up allocation for reference-type chain objects
Pierce Lopez [Fri, 17 Sep 2021 03:21:26 +0000 (23:21 -0400)]
buffer: do not round up allocation for reference-type chain objects

Skip rounding up memory allocations for:
  * evbuffer_add_reference()
  * evbuffer_add_buffer_reference()
  * evbuffer_add_file_segment()

These chain objects only store small structs with references to
other things, and these small structs do not themselves grow, so
bumping up the allocation to MIN_BUFFER_SIZE (512 bytes) is wasteful.

3 years agotest: skip dns_initialize_nameservers if missing /etc/resolv.conf
Pierce Lopez [Tue, 14 Sep 2021 05:19:36 +0000 (01:19 -0400)]
test: skip dns_initialize_nameservers if missing /etc/resolv.conf

some build systems run tests in minimal containers with no resolv.conf,
and the primary thing this test does is load the default /etc/resolv.conf

3 years agodoc: adjust flags notice on event_base_loop()
Yong Wu [Sun, 12 Sep 2021 10:03:03 +0000 (18:03 +0800)]
doc: adjust flags notice on event_base_loop()

3 years agoev_io_timeout consistency
Yong Wu [Mon, 6 Sep 2021 00:06:10 +0000 (08:06 +0800)]
ev_io_timeout consistency

3 years agomodify typo - timeeouts
Yong Wu [Sun, 5 Sep 2021 14:42:04 +0000 (22:42 +0800)]
modify typo - timeeouts

3 years agohttp: fix building under windows (guard with _WIN32 for unixsocket free)
Azat Khuzhin [Wed, 11 Aug 2021 22:40:27 +0000 (01:40 +0300)]
http: fix building under windows (guard with _WIN32 for unixsocket free)

Reported-by: @kaend
3 years agotest: fix checking test args for http_parse_uri_test
Azat Khuzhin [Tue, 10 Aug 2021 20:14:01 +0000 (23:14 +0300)]
test: fix checking test args for http_parse_uri_test

3 years agohttp: support unix domain sockets
Sean Young [Sun, 31 Jan 2016 11:31:00 +0000 (11:31 +0000)]
http: support unix domain sockets

There are no standard for encoding a unix socket in an url. nginx uses:

    http://unix:/path/to/unix/socket:/httppath

The second colon is needed to delimit where the unix path ends and where
the rest of the url continues.

Signed-off-by: Sean Young <sean@mess.org>
3 years agobuffer: fix CreateFileMapping() leak from evbuffer_add_file()
Azat Khuzhin [Sun, 1 Aug 2021 08:53:17 +0000 (11:53 +0300)]
buffer: fix CreateFileMapping() leak from evbuffer_add_file()

evbuffer_file_segment_materialize() is called twice from
evbuffer_add_file(), and so win32 mapping will leak.

Fixes: #1186
3 years agofix evthread_use_pthreads_with_flags dead lock when first return
moonlightsh [Fri, 16 Jul 2021 02:21:06 +0000 (10:21 +0800)]
fix evthread_use_pthreads_with_flags dead lock when first  return

3 years agobuild: fail with a useful error message if pkg-config isn't available
fanquake [Tue, 13 Jul 2021 07:08:44 +0000 (15:08 +0800)]
build: fail with a useful error message if pkg-config isn't available

3 years agoProperly initialize sockaddr length on systems with sin_len.
Tobias Heider [Tue, 6 Jul 2021 15:40:58 +0000 (17:40 +0200)]
Properly initialize sockaddr length on systems with sin_len.

3 years agoMerge remote-tracking branch 'upstream/pr/1171'
Azat Khuzhin [Fri, 9 Jul 2021 21:12:21 +0000 (00:12 +0300)]
Merge remote-tracking branch 'upstream/pr/1171'

* upstream/pr/1171:
  ci: install pkg-config in mingw-w64 CI
  build: test ac_cv_header_sys_time_h once, reformat timer* macro checks
  build: remove call to AC_C_CONST()
  build: replace ntp_pkg_config macro with a call to PKG_PROG_PKG_CONFIG()
  build: remove NTP_PKG_CONFIG call from libevent_mbedtls.m4
  build: stop using the deprecated form of AC_OUTPUT()
  build: quote args in AC_ARG_ENABLE & AS_HELP_STRING
  build: remove call to AC_HEADER_TIME
  build: call AC_PREREQ() first & quote argument
  build: remove call to AC_PREFIX_DEFAULT
  build: remove call to AC_PROG_GCC_TRADITIONAL

3 years agoci: install pkg-config in mingw-w64 CI
fanquake [Fri, 9 Jul 2021 04:34:37 +0000 (12:34 +0800)]
ci: install pkg-config in mingw-w64 CI

3 years agobuild: test ac_cv_header_sys_time_h once, reformat timer* macro checks
fanquake [Wed, 16 Jun 2021 07:29:30 +0000 (15:29 +0800)]
build: test ac_cv_header_sys_time_h once, reformat timer* macro checks

3 years agobuild: remove call to AC_C_CONST()
fanquake [Tue, 15 Jun 2021 08:00:48 +0000 (16:00 +0800)]
build: remove call to AC_C_CONST()

> This macro is obsolescent, as current C compilers support const.
> New programs need not use this macro.

See: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#index-AC_005fC_005fCONST-877.

3 years agobuild: replace ntp_pkg_config macro with a call to PKG_PROG_PKG_CONFIG()
fanquake [Tue, 15 Jun 2021 07:49:38 +0000 (15:49 +0800)]
build: replace ntp_pkg_config macro with a call to PKG_PROG_PKG_CONFIG()

Note that 0.15.0 is quite an old version to be testing for, however I've left
this as-is for now.

3 years agobuild: remove NTP_PKG_CONFIG call from libevent_mbedtls.m4
fanquake [Tue, 15 Jun 2021 07:37:30 +0000 (15:37 +0800)]
build: remove NTP_PKG_CONFIG call from libevent_mbedtls.m4

I'm guessing this was just copied from libevent_openssl.m4, however there aren't
actually any pkg-config calls / macros used here.

3 years agobuild: stop using the deprecated form of AC_OUTPUT()
fanquake [Tue, 15 Jun 2021 07:22:20 +0000 (15:22 +0800)]
build: stop using the deprecated form of AC_OUTPUT()

> The use of AC_OUTPUT with arguments is deprecated.

See: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#AC_005fOUTPUT.

3 years agobuild: quote args in AC_ARG_ENABLE & AS_HELP_STRING
fanquake [Tue, 15 Jun 2021 06:34:46 +0000 (14:34 +0800)]
build: quote args in AC_ARG_ENABLE & AS_HELP_STRING

Previously, some were, some weren't. Consolidate on quoting.

3 years agobuild: remove call to AC_HEADER_TIME
fanquake [Tue, 15 Jun 2021 06:10:29 +0000 (14:10 +0800)]
build: remove call to AC_HEADER_TIME

Besides the fact that the *_TIME_WITH_SYS_TIME define doesn't seem to be
used anywhere in the libevent source, this macro is also obselescent.

> This macro is obsolescent, as current systems can include both files when they exist.
> New programs need not use this macro.

See:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#index-AC_005fHEADER_005fTIME-640.

3 years agobuild: call AC_PREREQ() first & quote argument
fanquake [Tue, 15 Jun 2021 05:41:05 +0000 (13:41 +0800)]
build: call AC_PREREQ() first & quote argument

> This macro may be used before AC_INIT.

Calling this first means establishing that the required version of
autoconf is actually available, before bothering with AC_INIT().

See:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#Versioning.

3 years agobuild: remove call to AC_PREFIX_DEFAULT
fanquake [Tue, 15 Jun 2021 05:35:58 +0000 (13:35 +0800)]
build: remove call to AC_PREFIX_DEFAULT

> By default, configure sets the prefix for files it installs to /usr/local.

A call to AC_PREFIX_DEFAULT, just to set the value the same as the
default, would seem unnecessary. Note that the "initialize prefix"
comment dates back to aa6567fe6475d3230c7c745a7ca208735af0c331, prior to
when an autoconf macro was actually being used.

See:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#Default-Prefix.

3 years agobuild: remove call to AC_PROG_GCC_TRADITIONAL
fanquake [Tue, 15 Jun 2021 05:31:44 +0000 (13:31 +0800)]
build: remove call to AC_PROG_GCC_TRADITIONAL

libevent requires Autoconf 2.67+, and from atleast this version
onwards, if not earlier, this macro is obsolescent.

> This macro is obsolescent, since current versions of the GNU
> C compiler fix the header files automatically when installed.

See:
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.67/autoconf.html#AC_005fPROG_005fGCC_005fTRADITIONAL.

3 years agoMerge #1176 - make evthread_use_pthreads() a MT-Safe function
Azat Khuzhin [Sun, 27 Jun 2021 15:37:20 +0000 (18:37 +0300)]
Merge #1176 - make evthread_use_pthreads() a MT-Safe function

* upstream/pr/1176:
  remove emty line for code formating
  make evthread_use_pthreads a MT-Safe function

3 years agoremove emty line for code formating
moonlightsh [Fri, 25 Jun 2021 00:33:30 +0000 (08:33 +0800)]
remove emty line for code formating

3 years agomake evthread_use_pthreads a MT-Safe function
moonlightsh [Fri, 25 Jun 2021 00:27:27 +0000 (08:27 +0800)]
make evthread_use_pthreads a MT-Safe function

3 years agoRTEMS has no SA_RESTART
Michael Davidsaver [Mon, 21 Oct 2019 18:41:19 +0000 (11:41 -0700)]
RTEMS has no SA_RESTART

as RTEMS has no syscalls to restart.

3 years agoSwitch to lukka/run-vcpkg@v7 and update vcpkgGitCommitId
Azat Khuzhin [Tue, 23 Mar 2021 06:50:03 +0000 (09:50 +0300)]
Switch to lukka/run-vcpkg@v7 and update vcpkgGitCommitId

Let's see if it uses set-env or not [1]:

    Run lukka/run-vcpkg@v2
    Restore vcpkg and its artifacts from cache
    Set output env vars
      Error: Unable to process command '::set-env name=RUNVCPKG_VCPKG_ROOT::D:\a\libevent\vcpkg' successfully.
      Error: The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

  [1]: https://github.com/libevent/libevent/runs/2172680596?check_suite_focus=true#step:4:24

And this one [2]:

    error: could not open file /var/cache/pacman/pkg/libzstd-1.5.0-1-x86_64.pkg.tar.zst: Child process exited with status 127
    error: could not open file /var/cache/pacman/pkg/zstd-1.5.0-1-x86_64.pkg.tar.zst: Child process exited with status 127
    error: could not open file /var/cache/pacman/pkg/pacman-5.2.2-23-x86_64.pkg.tar.zst: Child process exited with status 127
    error: failed to commit transaction (cannot open package file)

  [2]: https://github.com/libevent/libevent/pull/1168/checks?check_run_id=2706159518#step:4:367

3 years agoReplace gettimeofday with the portable wrapper
Alex Budovski [Sun, 30 May 2021 18:05:25 +0000 (13:05 -0500)]
Replace gettimeofday with the portable wrapper

Otherwise the Win32 build fails.

3 years agoFix -Warray-parameter for evutil_ersatz_socketpair_()
Azat Khuzhin [Mon, 24 May 2021 18:03:58 +0000 (21:03 +0300)]
Fix -Warray-parameter for evutil_ersatz_socketpair_()

3 years agodns-example: add CNAME support
Azat Khuzhin [Mon, 24 May 2021 18:03:58 +0000 (21:03 +0300)]
dns-example: add CNAME support

3 years agoevdns: add ability to get CNAME
Sergey Matveychuk [Wed, 7 Apr 2021 17:39:18 +0000 (20:39 +0300)]
evdns: add ability to get CNAME

Add new flag (DNS_CNAME_CALLBACK) for
evdns_base_resolve_ipv4()/evdns_base_resolve_ipv6().

If set, you will get one more callback with type == DNS_CNAME and CNAME
in addrs argument.

3 years agocmake: don't override CMAKE_CONFIGURATION_TYPES.
Paweł Wegner [Thu, 13 May 2021 15:32:11 +0000 (17:32 +0200)]
cmake: don't override CMAKE_CONFIGURATION_TYPES.

Surprisingly this overrides configuration types for projects which embed libevent using cmake's add_subdirectory.

3 years agocmake: Fix generted pkgconfig files.
Biswapriyo Nath [Tue, 4 May 2021 19:56:17 +0000 (01:26 +0530)]
cmake: Fix generted pkgconfig files.

Use lowercase 'L' option for library names because uppercase 'L' is used with library search directory.

3 years agoSupport disabled renegotiation in mbedTLS
Azat Khuzhin [Fri, 30 Apr 2021 07:15:45 +0000 (10:15 +0300)]
Support disabled renegotiation in mbedTLS

Patch from: @Kurruk007
Fixes: #1161
3 years agoDo not wrap lines in AC_CHECK_HEADERS/AC_CHECK_FUNCS (fixes detection in mingw)
Azat Khuzhin [Tue, 27 Apr 2021 18:15:03 +0000 (21:15 +0300)]
Do not wrap lines in AC_CHECK_HEADERS/AC_CHECK_FUNCS (fixes detection in mingw)

Fixes: d433f847 ("Revert "build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS"")
Fixes: 28f0fe6f ("build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS")
Fixes: ce028cef ("build: fix autotools build under mingw")
3 years agoFix O_RDONLY (_O_RDONLY) under mingw
Azat Khuzhin [Tue, 27 Apr 2021 06:03:42 +0000 (09:03 +0300)]
Fix O_RDONLY (_O_RDONLY) under mingw

O_RDONLY is defined only if [1]:

    !defined(NO_OLDNAMES) || defined(_POSIX)

  [1]: https://github.com/Alexpux/mingw-w64/blob/d0d7f784833bbb0b2d279310ddc6afb52fe47a46/mingw-w64-headers/crt/fcntl.h#L35

3 years agoRetry write on EINTR in signal handler
Mike Sharov [Sun, 25 Apr 2021 13:12:29 +0000 (09:12 -0400)]
Retry write on EINTR in signal handler

The signal handler writes the received signal number as a byte value
into the notification pipe. If two signals are received in quick
succession, one of the writes may fail with EINTR without writing the
byte. This commit will check for EINTR and retry the write. If the error
is other than EINTR, a warning will be logged.

Note, that:
- on systems with sigaction libevent uses sigaction with SA_RESTART
- on linux writing to pipe is restartable and firstly it will try to
  write that byte so linux should not be affected in any form [1].

  [1]: https://elixir.bootlin.com/linux/latest/source/fs/pipe.c#L545

3 years agotest/regress.h: Increase default timeval tolerance 50 ms -> 100 ms
Yi Fan Yu [Fri, 23 Apr 2021 02:35:59 +0000 (22:35 -0400)]
test/regress.h: Increase default timeval tolerance 50 ms -> 100 ms

The default timeout tolerance is 50 ms,
which causes intermittent failure in many the
related tests in arm64 QEMU.

See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14163
(The root cause seems to be a heavy load)

Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
3 years agoMerge #1152 -- remove no op evdns functions
Azat Khuzhin [Sat, 3 Apr 2021 09:50:53 +0000 (12:50 +0300)]
Merge #1152 -- remove no op evdns functions

* upstream/pr/1152:
  dns: remove evdns_set_transaction_id_fn
  dns: remove evdns_set_random_bytes_fn

3 years agosample: use unsigned short instead of int for port
Emil Engler [Fri, 2 Apr 2021 19:02:12 +0000 (21:02 +0200)]
sample: use unsigned short instead of int for port

The C standard gurantees that an unsigned short is at least up to 65535
huge. Enough to store every TCP port. Also the parameter PORT is
overgiven to the `htons()` function which assumes that the parameter is
of type `uint16_t` which unsigned short is on most platforms.

3 years agodns: remove evdns_set_transaction_id_fn
fanquake [Sat, 3 Apr 2021 04:55:32 +0000 (12:55 +0800)]
dns: remove evdns_set_transaction_id_fn

3 years agodns: remove evdns_set_random_bytes_fn
fanquake [Sat, 3 Apr 2021 04:55:11 +0000 (12:55 +0800)]
dns: remove evdns_set_random_bytes_fn

3 years agodoc: adjust edge-trigger notice on event_new()
Emil Engler [Fri, 2 Apr 2021 18:59:55 +0000 (20:59 +0200)]
doc: adjust edge-trigger notice on event_new()

This makes it easier to read and to understand it in my opinon. It also
fixes a missing "-" character.

3 years agoRevert "build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS"
Azat Khuzhin [Fri, 2 Apr 2021 06:19:55 +0000 (09:19 +0300)]
Revert "build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS"

That commit was wrong, it breaks syntax for autoconf <2.71, since
AC_CHECK_*S() requires sh-like list.

This reverts commit 28f0fe6fd1e2b1e9fb24a5c7a5b078790890e44f.

Fixes: #1149
3 years agobuild: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS
Azat Khuzhin [Sun, 28 Mar 2021 14:16:54 +0000 (17:16 +0300)]
build: use literals for AC_CHECK_HEADERS/AC_CHECK_FUNCS

autoconf 2.72 reports:

    configure.ac:188: warning: AC_CHECK_HEADERS(\
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/headers.m4:217: AC_CHECK_HEADERS is expanded from...
    configure.ac:188: the top level
    configure.ac:188: warning: AC_CHECK_HEADERS(afunix.h
    ): you should use literals

And also it fails to find fcntl.h and other headers because of this:

    configure:14725: checking for  fcntl.h
    configure:14725: gcc -c -I/mingw64/include  conftest.c >&5
    conftest.c:77:10: fatal error:  fcntl.h: No such file or directory
       77 | #include < fcntl.h>

Refs: https://github.com/libevent/libevent/pull/1146/checks?check_run_id=2211752215

3 years agobuild: fix autotools build under mingw
Azat Khuzhin [Sun, 28 Mar 2021 06:01:58 +0000 (09:01 +0300)]
build: fix autotools build under mingw

autotools that is shipped with mingw (autoconf 2.71-1, automake
1.6-1.16, automake wrapper 11-1), does not allow trailing backslashes
for AC_CHECK_HEADERS() and AC_CHECK_FUNCS(), otherwise it generates
incorrect for loop, and reports:

    ../configure: line 14724: syntax error near unexpected token `as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`'
    ../configure: line 14724: `  as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh`'
    Error: Process completed with exit code 1.

Here is a simple analog:

    for VAR in <CR> foo \ <CR> bar \
    do :
        echo $VAR
    done

Trailing slash is not allowed.

Refs:
- https://github.com/libevent/libevent/runs/2171607687
- https://github.com/libevent/libevent/runs/2211365885?check_suite_focus=true

3 years agobuild: remove no-longer used checks for vasprintf
fanquake [Sun, 28 Mar 2021 02:35:22 +0000 (10:35 +0800)]
build: remove no-longer used checks for vasprintf

From what I can tell the last usage was removed in
8d1317d71c46e27c5073d3429a64af69de0351a6.

3 years agobuild: remove splice implementation fragments
fanquake [Sun, 28 Mar 2021 02:57:11 +0000 (10:57 +0800)]
build: remove splice implementation fragments

Looks like a `splice` implementation was planned, but has clearly never
eventuated (the TODO comment is from ~12 years ago, in
8b5bd77415fb6634fadf08357676926fecf5f032). For now, it's probably better
to remove the unused code/correct the docs.

3 years agoci: fix upload-artifacts for linux dist build
Azat Khuzhin [Tue, 23 Mar 2021 06:40:30 +0000 (09:40 +0300)]
ci: fix upload-artifacts for linux dist build

Fixes [1]:

    Run actions/upload-artifact@v1
    Error: Path does not exist /home/runner/work/libevent/libevent/build
    Error: Exit code 1 returned from process: file name '/home/runner/runners/2.277.1/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

  [1]: https://github.com/libevent/libevent/runs/2172680722?check_suite_focus=true

3 years agoMerge branch 'http-fix-fd-leak'
Azat Khuzhin [Tue, 23 Mar 2021 06:10:00 +0000 (09:10 +0300)]
Merge branch 'http-fix-fd-leak'

* http-fix-fd-leak:
  http: fix fd leak on fd reset (by using bufferevent_replacefd())
  bufferevent: introduce bufferevent_replacefd() (like setfd() but also close fd)

Fixes: #1143
3 years agohttp: fix fd leak on fd reset (by using bufferevent_replacefd())
Azat Khuzhin [Tue, 23 Mar 2021 06:02:39 +0000 (09:02 +0300)]
http: fix fd leak on fd reset (by using bufferevent_replacefd())

Fixes: afa66ea4 ("http: eliminate redundant bev fd manipulating and caching [WIP]")
3 years agobufferevent: introduce bufferevent_replacefd() (like setfd() but also close fd)
Azat Khuzhin [Tue, 23 Mar 2021 06:00:24 +0000 (09:00 +0300)]
bufferevent: introduce bufferevent_replacefd() (like setfd() but also close fd)

3 years agobuild: use AC_CHECK_LIB over AC_HAVE_LIBRARY
fanquake [Tue, 23 Mar 2021 01:52:14 +0000 (09:52 +0800)]
build: use AC_CHECK_LIB over AC_HAVE_LIBRARY

AC_HAVE_LIBRARY is deprecated, see
https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Obsolete-Macros.html,
and has been prior to Autoconf 2.67, which is the minimum required by
the project. It's usage also causes warnings with newer versions of autoconf:
```bash
configure.ac:319: warning: The macro `AC_HAVE_LIBRARY' is obsolete.
configure.ac:319: You should run autoupdate.
```

`AC_HAVE_LIBRARY` was introduced in #969, although it's not clear why it
was decided to revert to using an obselete macro.

3 years agofix compile error in VS2012 in evutil_gettimeofday()
MKCKR [Tue, 16 Feb 2021 05:26:44 +0000 (13:26 +0800)]
fix compile error in VS2012 in evutil_gettimeofday()

Move static variable definition before other statement, to prevent
compile error in VS2012.

Fixes: #1135
3 years agohttp: fix invalid unsigned arithmetic
ihsinme [Fri, 5 Feb 2021 15:54:30 +0000 (18:54 +0300)]
http: fix invalid unsigned arithmetic

3 years agoCheck return value of evbuffer_remove() in bufferevent_read()
lilei [Wed, 3 Feb 2021 06:19:57 +0000 (14:19 +0800)]
Check return value of evbuffer_remove() in bufferevent_read()

The conflict cast convertion between the return value of
bufferevent_read() and evbuffer_remove(), int(-1)->size_t(An undefined
maximum)

Add test case of bufferevent_read() should return 0 in case of
evbuffer_remove() returns -1

Fixes: #1132
3 years agotest/regress_http: cover reading of chunked payload by server
Azat Khuzhin [Mon, 18 Jan 2021 20:23:42 +0000 (23:23 +0300)]
test/regress_http: cover reading of chunked payload by server

This is an example with transfer-encoding by client via bufferevent for
the #1131

3 years agoevdns: add max-probe-timeout/probe-backoff-factor settings
chux0519 [Sat, 9 Jan 2021 09:19:27 +0000 (17:19 +0800)]
evdns: add max-probe-timeout/probe-backoff-factor settings

I recently found that when the network status changed when calling
bufferevent_socket_connect_hostname (e.g. switching between several
WIFIs), all DNS servers would fail, and the timeout of probe would be
very long if there were many DNS requests. I want libevent to support
manual setting of MAX_PROBE_TIMEOUT and TIMEOUT_BACKOFF_FACTOR

So move hardcoded MAX_PROBE_TIMEOUT and TIMEOUT_BACKOFF_FACTOR into
struct, and allow changing them.

3 years agodoc: remove dead link
Emil Engler [Sat, 26 Dec 2020 08:07:07 +0000 (09:07 +0100)]
doc: remove dead link

The link is dead and an archived page cannot be found in the
web.archive.org.

3 years agocmake: do not link libevent with libevent_core
Loïc Yhuel [Mon, 23 Nov 2020 16:24:36 +0000 (17:24 +0100)]
cmake: do not link libevent with libevent_core

When add_event_library macro was called without the INNER_LIBRARIES parameter, it reused the
value set by a previous call, since the INNER_LIBRARIES variable was not reset.

3 years agoDo not try to do SSL handshake if the connect() fails
Azat Khuzhin [Wed, 4 Nov 2020 21:57:39 +0000 (00:57 +0300)]
Do not try to do SSL handshake if the connect() fails

This will avoid this icky error:

    $ https-client -4 -url https://127.1
    some request failed - no idea which one though!
    error:00000005:lib(0):func(0):DH lib

And instead will report only:

    $ https-client -4 -url https://127.1
    some request failed - no idea which one though!
    socket error = Connection refused (111)

Refs: #1115

3 years agoMerge branch 'macos-brew-openssl-v2'
Azat Khuzhin [Mon, 2 Nov 2020 07:01:41 +0000 (10:01 +0300)]
Merge branch 'macos-brew-openssl-v2'

By Azat Khuzhin (2) and fanquake (1)
* macos-brew-openssl-v2:
  Add autodetection of openssl via brew into build matrix
  cmake: find openssl prefix via brew
  autotools: attempt to find OpenSSL via homebrew on macOS

Closes: #1050 (cherry picked one patch from it)
3 years agoAdd autodetection of openssl via brew into build matrix
Azat Khuzhin [Sun, 1 Nov 2020 21:39:26 +0000 (00:39 +0300)]
Add autodetection of openssl via brew into build matrix