4530 Commits

Author SHA1 Message Date
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
MKCKR
00b92f42b6 fix compile error in VS2012 in evutil_gettimeofday()
Move static variable definition before other statement, to prevent
compile error in VS2012.

Fixes: #1135
2021-02-17 01:11:07 +03:00
ihsinme
d13b7bbfcf http: fix invalid unsigned arithmetic 2021-02-11 21:14:42 +03:00
lilei
bc25889fb3 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
2021-02-04 00:20:36 +03:00
Azat Khuzhin
f17eb6f509 test/regress_http: cover reading of chunked payload by server
This is an example with transfer-encoding by client via bufferevent for
the #1131
2021-01-19 01:23:42 +03:00
chux0519
617ba83874 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.
2021-01-12 10:56:13 +03:00
Emil Engler
c5e4391b86
doc: remove dead link
The link is dead and an archived page cannot be found in the
web.archive.org.
2020-12-26 09:07:19 +01:00
Loïc Yhuel
657e180694 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.
2020-11-23 17:24:36 +01:00
Azat Khuzhin
59e31c9667 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
2020-11-05 00:57:39 +03:00
Azat Khuzhin
4f8a6320ca 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)
2020-11-02 10:01:41 +03:00
Azat Khuzhin
29b1404ba2 Add autodetection of openssl via brew into build matrix 2020-11-02 01:14:58 +03:00
Azat Khuzhin
1a242e1c96 cmake: find openssl prefix via brew 2020-11-02 01:14:58 +03:00
fanquake
72d877a2c2 autotools: attempt to find OpenSSL via homebrew on macOS
When compiling for macOS, where users will likely have OpenSSL installed
via brew, rather than available on the system, use brew  --prefix to
figure out where OpenSSL is, and then augment the pkg-config path so
that libs are found.
2020-11-01 23:34:10 +03:00
Azat Khuzhin
8d21ddcf4b Fix bufferevent_ssl_*flags() w/ disabled OpenSSL but enabled mbedTLS 2020-11-01 00:59:16 +03:00
Azat Khuzhin
8daa1aba3d Merge branch 'ssl-nagle'
* ssl-nagle:
  Introduce new BUFFEREVENT_SSL_BATCH_WRITE flag to avoid Nagle effect in SSL
  Introduce new API for flags of the SSL bufferevent
2020-10-31 23:04:55 +03:00
Azat Khuzhin
a490172d69 Introduce new BUFFEREVENT_SSL_BATCH_WRITE flag to avoid Nagle effect in SSL 2020-10-31 23:04:46 +03:00
Azat Khuzhin
7e0fc878c5 Introduce new API for flags of the SSL bufferevent
Introduce more generic API (like for evbuffer):
- bufferevent_ssl_set_flags()
- bufferevent_ssl_clear_flags()
- bufferevent_ssl_get_flags()

And deprecate existing:
- bufferevent_openssl_get_allow_dirty_shutdown()
- bufferevent_openssl_set_allow_dirty_shutdown()
- bufferevent_mbedtls_get_allow_dirty_shutdown()
- bufferevent_mbedtls_set_allow_dirty_shutdown()
2020-10-31 22:51:40 +03:00
Azat Khuzhin
587f6c83a3 Merge branch 'ssl-fixes-after-mbedtls'
* ssl-fixes-after-mbedtls:
  Fix BEV_IS_SSL() macro
  Fix preprocessor condition for BEV_IS_SSL()
  Remove reduntant BEV_IS_MBEDTLS

Refs: #1028
2020-10-31 22:50:11 +03:00
Azat Khuzhin
2484500ac2 Fix BEV_IS_SSL() macro
We cannot use the same trick with external declaration,
since there are copy of bufferevent_ops_ssl in each library:
- openssl
- mbedlts

However we can just compare the name of the bufferevent type for now.
(It is totally fine to use memcmp() here since it will be optimized by the compiler).
2020-10-31 22:50:04 +03:00
Azat Khuzhin
db6e22c7db Fix preprocessor condition for BEV_IS_SSL() 2020-10-31 22:50:04 +03:00
Azat Khuzhin
39ca97ef4d Remove reduntant BEV_IS_MBEDTLS 2020-10-31 22:27:28 +03:00
Azat Khuzhin
afa66ea420 http: eliminate redundant bev fd manipulating and caching [WIP]
At the very beginning we reset the bufferevent fd (if bev has it), which
is not a good idea, since if user passes bufferevent with existing fd he
has some intention.

So we need to:
- use BEV_OPT_CLOSE_ON_FREE for default bufferevent_socket_new() (to
  avoid manual shutdown/closee)
- drop getsockopt(SOL_SOCKET, SO_ERROR), since bufferevent already has
  evutil_socket_finished_connecting_()
- drop supperior bufferevent_setfd(bev, -1) in
  evhttp_connection_connect_()

Closes: #795
Refs: #875
2020-10-31 21:34:02 +03:00
Azat Khuzhin
67180f8c37 Merge branch 'ipv6-tiny-improvements'
* ipv6-tiny-improvements:
  http: add EVHTTP_URI_HOST_STRIP_BRACKETS
  http-server: add -H option to change listen address
  https-client: add newline into error messages
  https-client: add -4/-6 switches
2020-10-27 02:15:38 +03:00
Azat Khuzhin
e91c436388 http: add EVHTTP_URI_HOST_STRIP_BRACKETS
Refs: #1115
2020-10-27 02:13:21 +03:00
Azat Khuzhin
eb822ac751 http-server: add -H option to change listen address 2020-10-27 01:23:33 +03:00
Azat Khuzhin
6135248a0c https-client: add newline into error messages 2020-10-27 01:19:40 +03:00
Azat Khuzhin
f51ec25306 https-client: add -4/-6 switches 2020-10-27 01:18:52 +03:00
Azat Khuzhin
22872176a4 becat: add timeout (client/server) and verbosity (event_enable_debug_logging()) 2020-10-15 23:23:15 +03:00
guoxiang1996
6c644949d5
Change log message in evutil_make_socket_nonblocking in win32
Co-authored-by: guoxiang2 <guoxiang2@yy.com>
2020-10-10 22:23:14 +03:00
Azat Khuzhin
19d0bdfe0c Change prefix for man pages from "le_" to "libevent_"
As pointed by @kloczek:
  "With only two characters it would be harder to guess under what kind of name are libevent lvl 3 man pages.
   Longer name with bash/fix/zsh tab competition should not be a problem :)"

Refs: #1099
2020-10-04 22:59:12 +03:00
Azat Khuzhin
21b91692da Add prefix (le_) for man pages
This will:
- avoid overlapping (since there is util.h.3 page)
- group everything under some prefix (man le_<TAB><TAB> will show everything)

Fixes: #1099
2020-10-04 21:33:00 +03:00
Azat Khuzhin
3012c43808 Drop DOXYGEN_MAN_LINKS unsupported cmake flag
MAN_LINKS is not a variable in Doxyfile anyway.
2020-10-04 19:48:34 +03:00
Azat Khuzhin
852af060af http-server: add cli argument for max body size 2020-10-04 17:44:34 +03:00
Nikita Gorskikh
56e1213109 Remove dead code from bufferevent_socket_connect 2020-09-19 19:14:22 +03:00
Azat Khuzhin
9b270c5e02 Generate only real man pages with doxygen (MAN_LINKS=NO)
WIth MAN_LINKS=YES doxygen will generate ton's of man pages for each
field, function and so on, but it will not contain anything useful
except for link to another man page (header).

So to avoid man pages clashing, disable MAN_LINKS, and this will
generate man pages only for explicitly documented parts.

But even after this we have pretty non-unique man pages names:

    $ find install/ -name '*.3'
    install/share/man/man3/util.h.3
    ...

Looks like we should add prefix for each of them...
But let's see if there will be a problem.

Fixes: #1097
2020-09-16 08:27:10 +03:00