4614 Commits

Author SHA1 Message Date
Azat Khuzhin
2b92b830a7 http: fix building under windows (guard with _WIN32 for unixsocket free)
Reported-by: @kaend
2021-08-12 01:40:46 +03:00
Azat Khuzhin
86292628e3 test: fix checking test args for http_parse_uri_test 2021-08-10 23:22:10 +03:00
Sean Young
f446229b22 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>
2021-08-10 23:22:10 +03:00
Azat Khuzhin
6f139b8711 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
2021-08-01 12:05:43 +03:00
moonlightsh
c29f1dbe11 fix evthread_use_pthreads_with_flags dead lock when first return 2021-07-16 10:21:06 +08:00
fanquake
c5642697e7
build: fail with a useful error message if pkg-config isn't available 2021-07-13 15:08:44 +08:00
Tobias Heider
5c0e75c34e Properly initialize sockaddr length on systems with sin_len. 2021-07-12 13:52:59 +02:00
Azat Khuzhin
6d800fd6db 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
2021-07-10 00:12:21 +03:00
fanquake
196a36afc8
ci: install pkg-config in mingw-w64 CI 2021-07-09 12:58:38 +08:00
fanquake
7ab3a06ada
build: test ac_cv_header_sys_time_h once, reformat timer* macro checks 2021-07-09 12:34:11 +08:00
fanquake
041d6f0992
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.
2021-07-09 12:34:11 +08:00
fanquake
12996ba9bf
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.
2021-07-09 12:34:11 +08:00
fanquake
4ed3709637
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.
2021-07-09 12:34:10 +08:00
fanquake
7708f6ce11
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.
2021-07-09 12:34:10 +08:00
fanquake
5f11857fd7
build: quote args in AC_ARG_ENABLE & AS_HELP_STRING
Previously, some were, some weren't. Consolidate on quoting.
2021-07-09 12:34:10 +08:00
fanquake
67f808ece8
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.
2021-07-09 12:34:10 +08:00
fanquake
eb59d84da2
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.
2021-07-09 12:34:10 +08:00
fanquake
dfae9557fc
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.
2021-07-09 12:34:10 +08:00
fanquake
710ccb7e7c
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.
2021-07-09 12:34:09 +08:00
Azat Khuzhin
3d48c7563c 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
2021-06-27 18:37:20 +03:00
moonlightsh
bb669d934a remove emty line for code formating 2021-06-25 08:33:30 +08:00
moonlightsh
608876d256 make evthread_use_pthreads a MT-Safe function 2021-06-25 08:27:27 +08:00
Michael Davidsaver
73ca180188 RTEMS has no SA_RESTART
as RTEMS has no syscalls to restart.
2021-06-17 08:15:15 -07:00
Azat Khuzhin
aba6548c53 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
2021-05-31 10:36:08 +03:00
Alex Budovski
8f74b30c40 Replace gettimeofday with the portable wrapper
Otherwise the Win32 build fails.
2021-05-30 13:35:41 -05:00
Azat Khuzhin
c2b4524881 Fix -Warray-parameter for evutil_ersatz_socketpair_() 2021-05-24 21:03:58 +03:00
Azat Khuzhin
862b83f9b6 dns-example: add CNAME support 2021-05-24 21:03:58 +03:00
Sergey Matveychuk
19b3fd0bf0 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.
2021-05-24 21:03:45 +03:00
Paweł Wegner
087bbc572c cmake: don't override CMAKE_CONFIGURATION_TYPES.
Surprisingly this overrides configuration types for projects which embed libevent using cmake's add_subdirectory.
2021-05-14 14:07:30 +02:00
Biswapriyo Nath
1fe8b3d6a4 cmake: Fix generted pkgconfig files.
Use lowercase 'L' option for library names because uppercase 'L' is used with library search directory.
2021-05-05 01:26:17 +05:30
Azat Khuzhin
f02fa33948 Support disabled renegotiation in mbedTLS
Patch from: @Kurruk007
Fixes: #1161
2021-04-30 10:16:23 +03:00
Azat Khuzhin
7213806346 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")
2021-04-27 21:15:03 +03:00
Azat Khuzhin
86ae44ce4d Fix O_RDONLY (_O_RDONLY) under mingw
O_RDONLY is defined only if [1]:

    !defined(NO_OLDNAMES) || defined(_POSIX)

  [1]: d0d7f78483/mingw-w64-headers/crt/fcntl.h (L35)
2021-04-27 09:04:01 +03:00
Mike Sharov
4f8a61446c 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
2021-04-27 08:06:53 +03:00
Yi Fan Yu
dff8fd27ed 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>
2021-04-23 10:27:00 -04:00
Azat Khuzhin
8e03f49597 Merge #1152 -- remove no op evdns functions
* upstream/pr/1152:
  dns: remove evdns_set_transaction_id_fn
  dns: remove evdns_set_random_bytes_fn
2021-04-03 12:51:24 +03:00
Emil Engler
e77f187274 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.
2021-04-03 12:50:00 +03:00
fanquake
01beec2fea
dns: remove evdns_set_transaction_id_fn 2021-04-03 12:55:32 +08:00
fanquake
39d680534a
dns: remove evdns_set_random_bytes_fn 2021-04-03 12:55:11 +08:00
Emil Engler
0ef0d9475c 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.
2021-04-02 20:59:55 +02:00
Azat Khuzhin
d433f84733 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
2021-04-02 09:19:55 +03:00
Azat Khuzhin
28f0fe6fd1 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
2021-03-28 17:19:28 +03:00
Azat Khuzhin
ce028cefc7 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
2021-03-28 11:51:29 +03:00
fanquake
78e8541a9e
build: remove no-longer used checks for vasprintf
From what I can tell the last usage was removed in
8d1317d71c46e27c5073d3429a64af69de0351a6.
2021-03-28 13:55:59 +08:00
fanquake
4c29b01c87
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.
2021-03-28 10:57:11 +08:00
Azat Khuzhin
8e5e7bb8a8 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
2021-03-23 09:44:49 +03:00
Azat Khuzhin
3b9b655da9 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
2021-03-23 09:10:00 +03:00
Azat Khuzhin
2385638edf http: fix fd leak on fd reset (by using bufferevent_replacefd())
Fixes: afa66ea4 ("http: eliminate redundant bev fd manipulating and caching [WIP]")
2021-03-23 09:06:58 +03:00
Azat Khuzhin
aea752b62d bufferevent: introduce bufferevent_replacefd() (like setfd() but also close fd) 2021-03-23 09:06:58 +03:00
fanquake
8e6090d001
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.
2021-03-23 09:52:14 +08:00