]> granicus.if.org Git - libevent/log
libevent
2 years agotest: enable allocator_may_return_null=1 for calloc with ENOMEM test
Azat Khuzhin [Sun, 12 Feb 2023 16:05:20 +0000 (17:05 +0100)]
test: enable allocator_may_return_null=1 for calloc with ENOMEM test

2 years agotest: handle -v as --verbose for regress
Azat Khuzhin [Sun, 12 Feb 2023 15:46:40 +0000 (16:46 +0100)]
test: handle -v as --verbose for regress

2 years agotest: add del_wait/del_notify tests for windows
Azat Khuzhin [Sun, 12 Feb 2023 20:39:04 +0000 (21:39 +0100)]
test: add del_wait/del_notify tests for windows

Test manually, since CI is too slow

2 years agoFix compilation on non recent windows SDKs (#1399)
Edoardo Lolletti [Sun, 12 Feb 2023 15:19:35 +0000 (16:19 +0100)]
Fix compilation on non recent windows SDKs (#1399)

In commit f8bb9d8 the header stringapiset.h was included, very likely because the user who made the change saw that the funciton WideCharToMultiByte is "declared" in there.
That header tho is a recent addition to the windows headers added in the last years in an attempt from microsoft to split the windows.h header in multiple files, so the inclusion fails when the library is not built with the latest visual studio using the latest windows 10 sdk.
That inclusion can be safely removed as in any case the function WideCharToMultiByte was already included by the windows.h header that is included few lines below.

2 years agotest: fix leaks in bufferevent_pair_release_lock (#1413)
Azat Khuzhin [Sun, 12 Feb 2023 14:47:16 +0000 (15:47 +0100)]
test: fix leaks in bufferevent_pair_release_lock (#1413)

2 years agoRemove suppression for test_ok under TSan
Azat Khuzhin [Sun, 12 Feb 2023 08:56:54 +0000 (09:56 +0100)]
Remove suppression for test_ok under TSan

There is no such tests yet.

2 years agoMerge branch 'tests-fixes'
Azat Khuzhin [Sun, 12 Feb 2023 07:50:05 +0000 (08:50 +0100)]
Merge branch 'tests-fixes'

* tests-fixes:
  Add more ignore rules
  test: fix debug locks in case new lock gots old address
  test: suppress logs from the tests that produce them under normal circumstances
  test: fix TT_* flags values
  Suppress data race for test_ok variable
  Suppress data race for event_debug_created_threadable_ctx_ variable

2 years agoAdd more ignore rules
Azat Khuzhin [Sun, 12 Feb 2023 07:36:16 +0000 (08:36 +0100)]
Add more ignore rules

- for clangd
- and compile_commands.json for it

2 years agotest: fix debug locks in case new lock gots old address
Azat Khuzhin [Sun, 12 Feb 2023 07:34:52 +0000 (08:34 +0100)]
test: fix debug locks in case new lock gots old address

Refs: #1407

2 years agotest: suppress logs from the tests that produce them under normal circumstances
Azat Khuzhin [Sun, 12 Feb 2023 07:12:20 +0000 (08:12 +0100)]
test: suppress logs from the tests that produce them under normal circumstances

2 years agotest: fix TT_* flags values
Azat Khuzhin [Sun, 12 Feb 2023 06:59:17 +0000 (07:59 +0100)]
test: fix TT_* flags values

2 years agoSuppress data race for test_ok variable
Azat Khuzhin [Sun, 12 Feb 2023 06:58:55 +0000 (07:58 +0100)]
Suppress data race for test_ok variable

2 years agoSuppress data race for event_debug_created_threadable_ctx_ variable
Azat Khuzhin [Sun, 12 Feb 2023 06:58:29 +0000 (07:58 +0100)]
Suppress data race for event_debug_created_threadable_ctx_ variable

2 years agoAdd LEV_OPT_BIND_IPV4_AND_IPV6 flag (#1400)
Edoardo Lolletti [Sat, 4 Feb 2023 14:00:48 +0000 (15:00 +0100)]
Add LEV_OPT_BIND_IPV4_AND_IPV6 flag (#1400)

Libevent introduced the LEV_OPT_BIND_IPV6ONLY to pass to evconnlistener_new_bind to make it automatically set the underlying socket as accepting ipv6 requests. This works fine on posix compliant platforms as by the standard every new AF_INET6 socket is created as both supporting ipv6 and ipv4 connections. But on windows the default is the opposite, with the flag IPV6_V6ONLY  being always enabled by default.

This makes creating a listener to supports both protocols a bit more tricky as winsock doesn't allow changing this flag after evconnlistener_new_bind does all the initial setup because as stated in the docs, you can't change it after the sonnect connected, so one would have to manually create the socket beforehand and set the flag and then call evconnlistener_new with the socket itself.

It would be nice to have libevent keep a consistent behaviour across the platforms in this scenario, maybe or by making it always set IPV6_V6ONLY  to false unless LEV_OPT_BIND_IPV6ONLY is passed, in which case it's set to true, or add another flag to forcefully set it to false and keep the system dependent behaviour as default.

So this patch add new option for libevent listeners to bind to both - LEV_OPT_BIND_IPV4_AND_IPV6

2 years agoAdd config for vim/nvim
Azat Khuzhin [Sat, 4 Feb 2023 13:56:53 +0000 (14:56 +0100)]
Add config for vim/nvim

2 years agoFix pthread detection for regress tests on Android
Azat Khuzhin [Sat, 28 Jan 2023 12:28:52 +0000 (13:28 +0100)]
Fix pthread detection for regress tests on Android

Fixes: #1403
2 years agoFixes some new warnings under clang-15
Azat Khuzhin [Fri, 27 Jan 2023 07:57:33 +0000 (08:57 +0100)]
Fixes some new warnings under clang-15

- -Wdeprecated-non-prototype

  /src/le/libevent/strlcpy.c:48:1: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
  event_strlcpy_(dst, src, siz)

- -Wstrict-prototypes

  /src/le/libevent/evthread.c:82:70: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
  struct evthread_condition_callbacks *evthread_get_condition_callbacks()

- -Wunused-but-set-variable

  /src/le/libevent/test/regress_buffer.c:130:6: warning: variable 'n' set but not used [-Wunused-but-set-variable]
          int n = 0;
                                                                     ^

2 years agoAllow evdns_base_new to succeed with no nameservers configured (#1389)
Azat Khuzhin [Fri, 27 Jan 2023 07:51:56 +0000 (08:51 +0100)]
Allow evdns_base_new to succeed with no nameservers configured (#1389)

* evdns-no-ns:
  Allow evdns_base_new to succeed with no nameservers configured
  Replace magic numbers with consts for evdns_base_resolv_conf_parse() errors

2 years agoAllow evdns_base_new to succeed with no nameservers configured
Daniel Kempenich [Fri, 27 Jan 2023 07:44:41 +0000 (08:44 +0100)]
Allow evdns_base_new to succeed with no nameservers configured

If resolv.conf has no nameservers, evdns_base_new can still succeed with
the default of using the name server from localhost matching the man
page documentation for resolv.conf.

2 years agoReplace magic numbers with consts for evdns_base_resolv_conf_parse() errors
Daniel Kempenich [Wed, 18 Jan 2023 05:02:56 +0000 (23:02 -0600)]
Replace magic numbers with consts for evdns_base_resolv_conf_parse() errors

2 years agoFix ignoring return value of arc4random() warning (with _FORTIFY_SOURCE defined)
liaotonglang [Tue, 10 Jan 2023 03:20:24 +0000 (11:20 +0800)]
Fix ignoring return value of arc4random() warning (with _FORTIFY_SOURCE defined)

arc4random() defines with __wur (warn-unused-return) macro in glibc, but
the problem pops up only for gentoo, since only it really define __wur
to __attribute__ ((__warn_unused_result__)), because it defines
_FORTIFY_SOURCE unconditionally [1].

  [1]: https://gitweb.gentoo.org/proj/gcc-patches.git/tree/9.4.0/gentoo/01_all_default-fortify-source.patch?id=7f7f80a650607c3090ae0790b8daef88434da681

And hence you get this error:

```sh
docker run -v $PWD:/src:ro --rm --name le -w /src -it gentoo/stage3 bash -c 'mkdir /build && cd /build && /src/configure --enable-gcc-warnings=yes --disable-samples && make -j && echo OK'
/src/evutil_rand.c: In function 'evutil_secure_rng_init':
/src/evutil_rand.c:56:16: error: ignoring return value of 'arc4random' declared with attribute 'warn_unused_result' [-Werror=unused-result]
   56 |         (void) arc4random();
      |                ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:2056: evutil_rand.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/build'
make: *** [Makefile:1523: all] Error 2
```

Also it seems that GCC works as expected here [2], and will not change
the behavior.

  [2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425

2 years agoAdd CTestCostData.txt to gitignore
Azat Khuzhin [Sun, 15 Jan 2023 19:56:56 +0000 (20:56 +0100)]
Add CTestCostData.txt to gitignore

2 years agobuffer: use pread() for evbuffer_file_segment_materialize()
Dmitry Antipov [Mon, 2 Jan 2023 14:06:48 +0000 (17:06 +0300)]
buffer: use pread() for evbuffer_file_segment_materialize()

If pread(2) is available, prefer it over double lseek(2)
and read(2) in evbuffer_file_segment_materialize().

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2 years agoAllow CLI override of CMAKE_DEBUG_POSTFIX (#1391)
mdavidsaver [Fri, 16 Dec 2022 08:34:25 +0000 (00:34 -0800)]
Allow CLI override of CMAKE_DEBUG_POSTFIX (#1391)

Allows cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_DEBUG_POSTFIX= for a debug build with the regular library names.

2 years agoci: add CIFuzz Github action (#1382)
DavidKorczynski [Sat, 26 Nov 2022 19:40:02 +0000 (19:40 +0000)]
ci: add CIFuzz Github action (#1382)

Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2 years agoFix script for updating contributors
Azat Khuzhin [Sun, 20 Nov 2022 22:11:00 +0000 (23:11 +0100)]
Fix script for updating contributors

2 years agocmake: remove redundant _GNU_SOURCE definition
Azat Khuzhin [Sun, 20 Nov 2022 21:18:37 +0000 (22:18 +0100)]
cmake: remove redundant _GNU_SOURCE definition

As reported by @francoisk:

    `_GNU_SOURCE` is defined in the private config header but also on the
    compiler command-line for every object.

Fixes: #1333
2 years agoMerge branch 'release-2.2-changelog-prepare'
Azat Khuzhin [Sun, 20 Nov 2022 20:52:49 +0000 (21:52 +0100)]
Merge branch 'release-2.2-changelog-prepare'

* release-2.2-changelog-prepare:
  Changelog skeleton
  Start new changelog for 2.2

2 years agoChangelog skeleton
Azat Khuzhin [Sun, 20 Nov 2022 20:52:12 +0000 (21:52 +0100)]
Changelog skeleton

2 years agoStart new changelog for 2.2
Azat Khuzhin [Sun, 13 Nov 2022 21:09:12 +0000 (22:09 +0100)]
Start new changelog for 2.2

2 years agoMerge branch 'release-scripts'
Azat Khuzhin [Sun, 20 Nov 2022 20:50:40 +0000 (21:50 +0100)]
Merge branch 'release-scripts'

* release-scripts:
  Add a script to generate changelog
  Add a script to add new contributors
  Rellocate some text in CONTRIBUTORS.md

2 years agoAdd a script to generate changelog
Azat Khuzhin [Sun, 13 Nov 2022 20:53:17 +0000 (21:53 +0100)]
Add a script to generate changelog

2 years agoAdd a script to add new contributors
Azat Khuzhin [Sun, 13 Nov 2022 20:44:10 +0000 (21:44 +0100)]
Add a script to add new contributors

2 years agoRellocate some text in CONTRIBUTORS.md
Azat Khuzhin [Sun, 13 Nov 2022 20:32:44 +0000 (21:32 +0100)]
Rellocate some text in CONTRIBUTORS.md

2 years agocmake: do influence CMAKE_DEBUG_POSTFIX of the outer project (if any)
Azat Khuzhin [Sun, 20 Nov 2022 13:51:36 +0000 (14:51 +0100)]
cmake: do influence CMAKE_DEBUG_POSTFIX of the outer project (if any)

Consider the following example:

    $ touch lib.c
    $ cat > CMakeLists.txt <<EOL
    add_subdirectory(/src/le/libevent libevent EXCLUDE_FROM_ALL)
    add_library(lib lib.c)
    EOL
    $ mkdir .cmake
    $ cmake -DCMAKE_BUILD_TYPE=debug -G Ninja ..
    $ ninja
    $ ls *.a
    liblibd.a

So now outer project also has "d" prefix for libraries.

Let's avoid this by setting non-cached variable.

Fixes: #1371
2 years agoAdd ws-chat-server to gitignore (#1376)
Dmitry Ilyin [Wed, 16 Nov 2022 19:06:06 +0000 (22:06 +0300)]
Add ws-chat-server to gitignore (#1376)

2 years agoExclude arc4random_buf implementation if it's already present in the platform (#1375)
Srivatsan Iyer [Tue, 15 Nov 2022 07:08:41 +0000 (12:38 +0530)]
Exclude arc4random_buf implementation if it's already present in the platform (#1375)

This patch excludes definition of arc4random_buf on systems where it is already present. When the symbol is found, the macro EVENT__HAVE_ARC4RANDOM_BUF is set via CMake's configure_file(..).

Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2 years agoVarious documentation improvements (#842)
Azat Khuzhin [Sun, 13 Nov 2022 13:05:43 +0000 (14:05 +0100)]
Various documentation improvements (#842)

* doc-pull:
  doc: add build prerequisites
  doc: add MSVC and GNUC options

Fixes: #843
2 years agodoc: add build prerequisites
yuangongji [Fri, 21 Jun 2019 16:03:36 +0000 (00:03 +0800)]
doc: add build prerequisites

[ci skip]

2 years agodoc: add MSVC and GNUC options
yuangongji [Wed, 19 Jun 2019 14:27:39 +0000 (22:27 +0800)]
doc: add MSVC and GNUC options

2 years agoevdns: integrate deferred_response_callback into evdns_request
mkm [Tue, 1 Nov 2022 13:26:11 +0000 (14:26 +0100)]
evdns: integrate deferred_response_callback into evdns_request

the allocation of the struct deferred_reply_callback can fail. If that
happens a program waiting for a callback never gets a callback. The
program would asume that it either gets an error or a callback when e.g.
calling evdns_base_resolve_ipv6.

I did an analysis of the evdns.c code and concluded that struct
evdns_request would live until the callback is executed. Based on that
conclusion I removed the struct deferred_reply_callback and moved the
neccessary fields for data which should be copied from struct request
into struct evdns_request.

The fields evdns_callback_type user_callback and void *user_pointer are
moved into struct evdns_request as it is a more natural place for them
to live than struct request.

2 years agoAdd CI checks for OpenBSD (#1326)
neil [Sun, 13 Nov 2022 12:39:17 +0000 (20:39 +0800)]
Add CI checks for OpenBSD (#1326)

Initially 6.9 and 7.1 had been added, however due to some issues (you can read
about them below) 6.9 had been disabled.

netbsd 6.9 does not have correct library namings for autotools:

    2022-08-17T04:59:58.8339420Z libtool: link: (cd ".libs" && rm -f "libevent.so.1.0" && ln -s "libevent-2.2.so.1.0" "libevent.so.1.0")

    $ grep ^library_names= libevent.la·
    library_names='libevent-2.2.so.1.0 libevent.so.1.0'

    # And this is wrong, it should be:
    libtool: link: (cd ".libs" && rm -f "libevent-2.2.so.1" && ln -s "libevent-2.2.so.1.0.0" "libevent-2.2.so.1")
    libtool: link: (cd ".libs" && rm -f "libevent.so" && ln -s "libevent-2.2.so.1.0.0" "libevent.so")
    library_names='libevent-2.2.so.1.0.0 libevent-2.2.so.1 libevent.so'

**And I think that 7.1 should also fail, however it has system-wide libevent installed with evdns in the libevent.so**

Also there are some issues with `TEST_EXPORT_SHARED` test, because of libraries naming:

    2022-09-13T06:38:29.2150790Z [test-export] test for install tree(in system-wide path)
    2022-09-13T06:38:29.2151500Z [test-export] fail: link core and run core expects success but gets failure.
    2022-09-13T06:38:29.2063870Z /usr/bin/cc CMakeFiles/test-export.dir/test-export.c.o -o test-export   -L/usr/local/lib  -Wl,-z,origin,-rpath,/usr/local/lib -levent_core-2.2 -lpthread -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib·
    2022-09-13T06:38:29.2152190Z ld: error: unable to find library -levent_core-2.2

    2022-09-13T06:38:28.3915680Z -- Install configuration: "Release"
    2022-09-13T06:38:28.3916700Z -- Up-to-date: /usr/local/lib/libevent_core-2.2.so.1.0.0
    2022-09-13T06:38:28.3917110Z -- Up-to-date: /usr/local/lib/libevent_core-2.2.so.1
    2022-09-13T06:38:28.3917480Z -- Up-to-date: /usr/local/lib/libevent_core.so
    # no libevent_core-2.2.so

So I have to disable it too.

Co-authored-by: Azat Khuzhin <azat@libevent.org>
2 years agosignal: new signal handling backend based on signalfd
Dmitry Antipov [Tue, 25 Oct 2022 08:30:34 +0000 (11:30 +0300)]
signal: new signal handling backend based on signalfd

Linux-specific signal handling backend based on signalfd(2)
system call, and public function event_base_get_signal_method()
to obtain an underlying kernel signal handling mechanism.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2 years agoIgnore unknown pragmas
Azat Khuzhin [Sat, 12 Nov 2022 17:56:25 +0000 (18:56 +0100)]
Ignore unknown pragmas

Since new compilers has new checks (like -Wdangling-pointer), and so to
avoid extra checks in cmake/autotools, simply suppress if the pragma is
unknown.

2 years agows-chat-server: fix session name initialization (using of uninitialized data)
Azat Khuzhin [Sat, 12 Nov 2022 17:59:41 +0000 (18:59 +0100)]
ws-chat-server: fix session name initialization (using of uninitialized data)

2 years agocmake: tiny cleanup
Azat Khuzhin [Sat, 12 Nov 2022 17:56:03 +0000 (18:56 +0100)]
cmake: tiny cleanup

2 years agows: ignore case while comparing values of Upgrade/Connection headers
Azat Khuzhin [Sat, 12 Nov 2022 17:45:13 +0000 (18:45 +0100)]
ws: ignore case while comparing values of Upgrade/Connection headers

Cc: @widgetii
Fixes: #1373
2 years agows-chat-server: avoid SIGSEGV in case of evws_new_session() failure
Azat Khuzhin [Sat, 12 Nov 2022 17:44:44 +0000 (18:44 +0100)]
ws-chat-server: avoid SIGSEGV in case of evws_new_session() failure

2 years agosample/ws-chat.html: allow to open it via file:// protocol
Azat Khuzhin [Sat, 12 Nov 2022 17:11:08 +0000 (18:11 +0100)]
sample/ws-chat.html: allow to open it via file:// protocol

2 years agoSuppress -Wdangling-pointer in event_signal_closure()
Azat Khuzhin [Sat, 12 Nov 2022 17:06:09 +0000 (18:06 +0100)]
Suppress -Wdangling-pointer in event_signal_closure()

gcc 12 complains:

    [34/46] Building C object CMakeFiles/event_static.dir/event.c.o
    /src/le/libevent/event.c: In function ‘event_signal_closure’:
    /src/le/libevent/event.c:1384:32: warning: storing the address of local variable ‘ncalls’ in ‘*ev.ev_.ev_signal.ev_pncalls’ [-Wdangling-pointer=]
     1384 |                 ev->ev_pncalls = &ncalls;
          |                 ~~~~~~~~~~~~~~~^~~~~~~~~
    /src/le/libevent/event.c:1378:15: note: ‘ncalls’ declared here
     1378 |         short ncalls;
          |               ^~~~~~
    /src/le/libevent/event.c:1378:15: note: ‘ev’ declared here

2 years agosha1: ignore -Wstringop-overread warning
Azat Khuzhin [Sat, 12 Nov 2022 16:56:51 +0000 (17:56 +0100)]
sha1: ignore -Wstringop-overread warning

Fixes the following:

    [4/38] Building C object CMakeFiles/event_shared.dir/sha1.c.o
    In function ‘SHA1Update’,
        inlined from ‘SHA1Final’ at /src/le/libevent/sha1.c:274:5,
        inlined from ‘builtin_SHA1’ at /src/le/libevent/sha1.c:292:5:
    /src/le/libevent/sha1.c:228:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 7 [-Wstringop-overread]
      228 |             SHA1Transform(context->state, *(const unsigned char (*)[64])&data[i]);
          |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /src/le/libevent/sha1.c:228:13: note: referencing argument 2 of type ‘const unsigned char[64]’
    /src/le/libevent/sha1.c: In function ‘builtin_SHA1’:
    /src/le/libevent/sha1.c:80:13: note: in a call to function ‘SHA1Transform’
       80 | static void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]) {
          |             ^~~~~~~~~~~~~

2 years agosha1: hide SHA1_CTX
Azat Khuzhin [Sat, 12 Nov 2022 15:41:55 +0000 (16:41 +0100)]
sha1: hide SHA1_CTX

2 years agoFix syntax error (#1369)
OgreTransporter [Fri, 4 Nov 2022 22:52:01 +0000 (23:52 +0100)]
Fix syntax error (#1369)

2 years agofixed missing check for null after strdup in evutil_inet_pton_scope (#1366)
Michael Madsen [Fri, 4 Nov 2022 08:59:17 +0000 (01:59 -0700)]
fixed missing check for null after strdup in evutil_inet_pton_scope (#1366)

2 years agows: fix compile error on centos 7 - very old compiler (#1359)
Leon George [Sun, 23 Oct 2022 11:47:23 +0000 (13:47 +0200)]
ws: fix compile error on centos 7 - very old compiler (#1359)

* http: fix typo

* ws: fix comile error

On CentOS:

  CC       ws.lo
ws.c: In function 'get_ws_frame':
ws.c:244:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (int i = 0; i < payload_len; i++) {
   ^
ws.c:244:3: note: use option -std=c99 or -std=gnu99 to compile your code

2 years agoFix data-race in ws code (#1360)
Azat Khuzhin [Sat, 22 Oct 2022 20:23:52 +0000 (22:23 +0200)]
Fix data-race in ws code (#1360)

@widgetii:

  "
  =================================================================
  ==985==ERROR: AddressSanitizer: heap-use-after-free on address 0xb24323e5 at pc 0xb6a06f1c bp 0x9fffc694 sp 0x9fffc260
  WRITE of size 2 at 0xb24323e5 thread T22
      #0 0xb6a06f1b in __interceptor_memcpy.part.43 (/usr/lib/libasan.so.5+0x41f1b)

  0xb24323e5 is located 229 bytes inside of 512-byte region [0xb2432300,0xb2432500)
  freed by thread T0 (app) here:
      #0 0xb6a849df in free (/usr/lib/libasan.so.5+0xbf9df)
      #1 0xb64b6e07 in evbuffer_drain (/usr/lib/libevent_core-2.2.so.1+0x9e07)

  previously allocated by thread T22 here:
      #0 0xb6a84d17 in __interceptor_malloc (/usr/lib/libasan.so.5+0xbfd17)
      #1 0xb64b3d1b  (/usr/lib/libevent_core-2.2.so.1+0x6d1b)
      #2 0x61223 in onIceCandidateHandler /home/dima/git/app/src/webrtc/local.c:116
      #3 0x19296f in onNewIceLocalCandidate /home/dima/git/webrtc-c/src/source/PeerConnection/PeerConnection.c:471
  "

* upstream/pr/1360:
  Remove bad copy-paste
  Add locks for server WS, fixes #1357

2 years agoRemove bad copy-paste
Dmitry Ilyin [Wed, 12 Oct 2022 19:15:21 +0000 (22:15 +0300)]
Remove bad copy-paste

2 years agoAdd locks for server WS, fixes #1357
Dmitry Ilyin [Wed, 12 Oct 2022 11:13:44 +0000 (14:13 +0300)]
Add locks for server WS, fixes #1357

2 years agocmake: Fix Android build.
Ryan Pavlik [Mon, 3 Oct 2022 14:31:10 +0000 (09:31 -0500)]
cmake: Fix Android build.

Android/Bionic C library needs no special flags to have threading support.
Found when trying to build with vcpkg.

2 years agoUse heap-bases contexts for MbedTLS handles (#1355)
Azat Khuzhin [Sat, 8 Oct 2022 16:26:24 +0000 (19:26 +0300)]
Use heap-bases contexts for MbedTLS handles (#1355)

@widgetii:

"Recently after studying [https-client.c code](https://github.com/libevent/libevent/blob/master/sample/https-client.c#L532) I found that I cannot use MbedTLS with `bufferevent_mbedtls_socket_new` same way as for OpenSSL in other than hello-world code. In mentioned sample code, ssl context is created by `SSL_new()` (as heap-based pointer), but for MbedTLS stack value is used. The issue is in different semantics because OpenSSL is responsible for memory allocation and release for its context, but for MbedTLS it turns out user should do the same manually.

I expect that in both cases, setting option `BEV_OPT_CLOSE_ON_FREE` will free all linked resources, but in case of MbedTLS I have memory leak after connection is closed.

My proposal is:
1. Provide new `mbedtls_ssl_new` helper-function for end-user that do the same job as `SSL_new()` and use it and example in sample:

```c
mbedtls_ssl_context *mbedtls_ssl_new(const mbedtls_ssl_config *conf) {
  mbedtls_ssl_context *ssl = calloc(1, sizeof(*ssl));
  mbedtls_ssl_init(ssl);
  mbedtls_ssl_setup(ssl, conf);
  return ssl;
}
```

2. Add `free(ctx->ssl)` right after https://github.com/libevent/libevent/blob/master/bufferevent_mbedtls.c#L68"

Fixes: #1354
2 years agoFix memleak in regress tests
Dmitry Ilyin [Tue, 4 Oct 2022 18:42:30 +0000 (21:42 +0300)]
Fix memleak in regress tests

2 years agoChange code for samples
Dmitry Ilyin [Tue, 4 Oct 2022 14:57:01 +0000 (17:57 +0300)]
Change code for samples

2 years agoAdd helpers and all regress tests are passed
Dmitry Ilyin [Tue, 4 Oct 2022 14:49:22 +0000 (17:49 +0300)]
Add helpers and all regress tests are passed

2 years agofix: arc4_getword integer overflow, detected by -fsanitize=undefined
jackerli(李剑) [Wed, 28 Sep 2022 08:41:59 +0000 (16:41 +0800)]
fix: arc4_getword integer overflow, detected by -fsanitize=undefined

2 years agoepoll: use epoll_pwait2() if available
Dmitry Antipov [Thu, 15 Sep 2022 11:06:50 +0000 (14:06 +0300)]
epoll: use epoll_pwait2() if available

On GNU/Linux with epoll backend, prefer epoll_pwait2() if available,
which is useful to support the timeout with microsecond precision.

2 years agoFix socketpair failure when temporary directory has non-latin character
zhenhaonong [Fri, 16 Sep 2022 07:55:56 +0000 (15:55 +0800)]
Fix socketpair failure when temporary directory has non-latin character

2 years agoAdd manual CMAKE_C_BYTE_ORDER set for old CMake
Dmitry Ilyin [Mon, 26 Sep 2022 08:54:14 +0000 (11:54 +0300)]
Add manual CMAKE_C_BYTE_ORDER set for old CMake

2 years agoci: disable freebsd 13.0 builds (due to issues in the image)
Azat Khuzhin [Wed, 14 Sep 2022 20:14:28 +0000 (22:14 +0200)]
ci: disable freebsd 13.0 builds (due to issues in the image)

Before it fails with:

   exec ssh: pkg install -y  mbedtls cmake python3
    /bin/bash /Users/runner/work/_actions/vmactions/freebsd-vm/v0/run.sh execSSH
    Config file: freebsd-13.0.conf
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    Warning: no access to tty (Bad file descriptor).
    Thus no job control in this shell.
    Installing pkg-1.18.3...
    Newer FreeBSD version for package pkg:
    To ignore this error set IGNORE_OSVERSION=yes
    - package: 1301000
    - running kernel: 1300139
    Ignore the mismatch and continue? [y/N]:
    Failed to install the following 1 package(s): /tmp//pkg.txz.18yvwm
    Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly, please wait...
    Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
    Error: The process '/bin/bash' failed with exit code 1

And now with:
  ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/lib/libpython3.9.so.1.0 not found

Commenting for now, anyway we do not need such huge CI matrix, because
we have only public workers, and they are pretty busy.

Cc: @Neilpang
2 years ago.github/workflows/build.yml: Cleanup trailing whitespaces
Azat Khuzhin [Wed, 14 Sep 2022 20:13:12 +0000 (22:13 +0200)]
.github/workflows/build.yml: Cleanup trailing whitespaces

2 years agoFix conflict with SHA1 function from openssl
Dmitry Ilyin [Wed, 14 Sep 2022 10:33:13 +0000 (13:33 +0300)]
Fix conflict with SHA1 function from openssl

2 years agoAdd minimal WebSocket server implementation for evhttp (#1322)
Dmitry Ilyin [Mon, 12 Sep 2022 19:16:56 +0000 (22:16 +0300)]
Add minimal WebSocket server implementation for evhttp (#1322)

This adds few functions to use evhttp-based webserver to handle incoming
WebSockets connections. We've tried to use both libevent and libwebsockets in
our application, but found that we need to have different ports at the same
time to handle standard HTTP and WebSockets traffic. This change can help to
stick only with libevent library.

Implementation was inspired by modified Libevent source code in ipush project
[1].

  [1]: https://github.com/sqfasd/ipush/tree/master/deps/libevent-2.0.21-stable

Also, WebSocket-based chat server was added as a sample.

2 years agoMake rekey interval less predictable (#1331)
Keelan Cannoo [Mon, 12 Sep 2022 19:12:47 +0000 (23:12 +0400)]
Make rekey interval less predictable (#1331)

2 years agoAdd openssl-compat.h into HDR_PRIVATE
Azat Khuzhin [Sun, 11 Sep 2022 20:08:32 +0000 (22:08 +0200)]
Add openssl-compat.h into HDR_PRIVATE

Fixes: #1334
2 years agoFix non-std printf %p arguments (#1327)
mareksm [Sun, 28 Aug 2022 12:27:04 +0000 (15:27 +0300)]
Fix non-std printf %p arguments (#1327)

* Fix non-std printf %p arguments when running with -Werror -pedantic-errors

Co-authored-by: Mareks Malnacs <mareks.malnacs>
2 years agotest: fix util/getaddrinfo for netbsd (v2)
Azat Khuzhin [Sun, 14 Aug 2022 07:56:50 +0000 (09:56 +0200)]
test: fix util/getaddrinfo for netbsd (v2)

Fixes: c198b0ce ("test: fix util/getaddrinfo for netbsd")
Fixes: #1316
2 years agoMerge pull request #1315 from yogo1212/http_per_socket_bebcb
Azat Khuzhin [Sat, 13 Aug 2022 22:46:48 +0000 (00:46 +0200)]
Merge pull request #1315 from yogo1212/http_per_socket_bebcb

In it's current form, libevent requires multiple struct evhttp objects to be created in order to enable listening on sockets with more than one type of encryption.

This change allows specifying per-socket how the associated bufferevents should be created.
Thus, it becomes possible to have multiple listening sockets with different encryption parameters using only one evttp.

2 years agotest: fix util/getaddrinfo for netbsd
Azat Khuzhin [Sat, 13 Aug 2022 18:48:00 +0000 (20:48 +0200)]
test: fix util/getaddrinfo for netbsd

Fixes: #1316
2 years agoFixed CMake configuration failure (libevent#1321)
Borys Smejda [Sat, 13 Aug 2022 17:10:10 +0000 (19:10 +0200)]
Fixed CMake configuration failure (libevent#1321)

Deleted usage of CMake feature 'file(REAL_PATH'
which is available from version 3.19
with an old 'get_filename_component' so that
older version of CMake can still be used
to configure the project.

2 years agohttp: allow setting bevcb per socket
Leon M. George [Mon, 1 Aug 2022 08:16:18 +0000 (10:16 +0200)]
http: allow setting bevcb per socket

Co-authored-by: Azat Khuzhin <azat@libevent.org>
v2: remove handling of HTTP_BIND_IPV6

2 years agotest: allow to run init_ssl() multiple times
Azat Khuzhin [Sat, 13 Aug 2022 17:51:02 +0000 (19:51 +0200)]
test: allow to run init_ssl() multiple times

2 years agotest: add a comment for init_ssl() about suppressions for LSan
Azat Khuzhin [Sat, 13 Aug 2022 17:51:45 +0000 (19:51 +0200)]
test: add a comment for init_ssl() about suppressions for LSan

2 years agoAdd check of mmap64 function and use it when available rather that mmap
Dmitry Ilyin [Sun, 7 Aug 2022 10:51:48 +0000 (13:51 +0300)]
Add check of mmap64 function and use it when available rather that mmap

There can be issues on 32-bit architectures to mmap 2+GiB file, and to
make this portable between different version of glibc, mmap64 was
prefered over _FILE_OFFSET_BITS

2 years agofix freebsd checks
neil [Sun, 7 Aug 2022 11:37:32 +0000 (19:37 +0800)]
fix freebsd checks

2 years agofix freebsd checks
neil [Sun, 7 Aug 2022 11:23:04 +0000 (19:23 +0800)]
fix freebsd checks

2 years agoAdd freebsd CI checks
neil [Sun, 7 Aug 2022 10:56:00 +0000 (18:56 +0800)]
Add freebsd CI checks
ci/linux skip
ci/macos skip
ci/windows skip
ci/mingw skip

2 years agoSearch library name of Debug for find_event_lib.
Haowei Hsu [Fri, 29 Jul 2022 12:58:27 +0000 (20:58 +0800)]
Search library name of Debug for find_event_lib.

2 years agoAdd postfix for Debug configuration.
Haowei Hsu [Fri, 29 Jul 2022 12:49:35 +0000 (20:49 +0800)]
Add postfix for Debug configuration.

2 years agoAdd more HTTP_ response codes
Dmitry Ilyin [Sat, 6 Aug 2022 11:23:53 +0000 (14:23 +0300)]
Add more HTTP_ response codes

2 years agoci: increase number of attempts to 5
Azat Khuzhin [Tue, 12 Jul 2022 18:57:41 +0000 (21:57 +0300)]
ci: increase number of attempts to 5

2 years agoci: add retries
Azat Khuzhin [Tue, 12 Jul 2022 18:08:00 +0000 (21:08 +0300)]
ci: add retries

Right now it is possible for some tests to fail, because of lack of CPU
time.
And it is better to have green CI even if this will take longer.

2 years agoci: use ubuntu 22.04 with clang 11 for sanitizers build (#1306)
Azat Khuzhin [Tue, 12 Jul 2022 07:07:04 +0000 (10:07 +0300)]
ci: use ubuntu 22.04 with clang 11 for sanitizers build (#1306)

* ci-tsan-recent:
  test: fix unused variable in rand test (catched by newer clang)
  ci: use ubuntu 22.04 with clang 11 for sanitizers build

2 years agotest: fix unused variable in rand test (catched by newer clang)
Azat Khuzhin [Tue, 12 Jul 2022 06:54:14 +0000 (09:54 +0300)]
test: fix unused variable in rand test (catched by newer clang)

2 years agoci: use ubuntu 22.04 with clang 11 for sanitizers build
Azat Khuzhin [Tue, 12 Jul 2022 05:03:36 +0000 (08:03 +0300)]
ci: use ubuntu 22.04 with clang 11 for sanitizers build

There are periodically some heap-use-after-free reported in ratelim
tests by TSan, which I cannot reproduce locally and even on CI it is
flaky.

Let's try to use recent clang, maybe it fixes some issues in sanitizers.

Refs: #1206

2 years agotest: increase timeout significantly in dns/getaddrinfo_cancel_stress (for TSan)
Azat Khuzhin [Mon, 11 Jul 2022 19:52:57 +0000 (22:52 +0300)]
test: increase timeout significantly in dns/getaddrinfo_cancel_stress (for TSan)

Fixes: #1304
2 years agoci: disable broken mingw cmake builds (#1207)
Azat Khuzhin [Mon, 11 Jul 2022 00:45:32 +0000 (03:45 +0300)]
ci: disable broken mingw cmake builds (#1207)

2 years agoSlightly adjust badges markdown in README
Azat Khuzhin [Mon, 11 Jul 2022 00:51:31 +0000 (03:51 +0300)]
Slightly adjust badges markdown in README

2 years agoci: fix master/upstream workflow (syntax error)
Azat Khuzhin [Mon, 11 Jul 2022 00:50:16 +0000 (03:50 +0300)]
ci: fix master/upstream workflow (syntax error)

2 years agoUpdate CI status badge
Azat Khuzhin [Mon, 11 Jul 2022 00:47:45 +0000 (03:47 +0300)]
Update CI status badge

2 years agoRework CI to keep everything in one workflow (by using reusable workflow)
Azat Khuzhin [Sun, 10 Jul 2022 13:49:53 +0000 (16:49 +0300)]
Rework CI to keep everything in one workflow (by using reusable workflow)

Right now because we have separate workflows there is no one page with
all the jobs, instead we have separate page for each workflow (linux,
windows, ...)

This is pretty inconvenient, so let's make it cleaner, and now we will
have only two:

- for pull requests
- for upstream/master

2 years agoevdns: accept domains up to 254 long (previosly only 63 long was accepted)
Azat Khuzhin [Sun, 10 Jul 2022 14:33:15 +0000 (17:33 +0300)]
evdns: accept domains up to 254 long (previosly only 63 long was accepted)

Previously evdns was using HOST_NAME_MAX, and define it to 255 *only* if
it not set, however it does set on linux:

    $ egrep -r define.*HOST_NAME_MAX /usr/include/bits
    /usr/include/bits/local_lim.h:#define HOST_NAME_MAX             64
    /usr/include/bits/posix1_lim.h:#define _POSIX_HOST_NAME_MAX     255
    /usr/include/bits/confname.h:#define _SC_HOST_NAME_MAX          _SC_HOST_NAME_MAX

But 64 should be the limit of the host component, not for the whole
hostname, as also noted by @ploxiln

So use our own EVDNS_NAME_MAX const, which is set to 255.

Fixes: #1280