4942 Commits

Author SHA1 Message Date
Azat Khuzhin
45e24185f5
Merge pull request #1470 from mdavidsaver/auto-detect-ssl
Both cmake and autoconf are capable of automatically detecting the presence of OpenSSL and MbedTLS.  However, the present build time logic doesn't do this.

With cmake, my starting point is to preserve the reversed logic of `EVENT__DISABLE_OPENSSL` and `EVENT__DISABLE_MBEDTLS`, adding a third option `AUTO` as the new default.  I'm following the pattern of this [post on the cmake list](https://cmake.org/pipermail/cmake/2016-October/064342.html).  `OFF` and `ON` should continue with their present behaviors.

With autoconf, I've tried to implement what I understand to be conventional behavior.  eg. `--enable-openssl` and `--disable-openssl` should continue to have the same effect.  The default if neither is passed is equivalent to the new `--enable-openssl=auto`.

I've also added another commit removing what I think is an unnecessary `break` in `m4/libevent_mbedtls.m4`, which I suspect is leftover from some copy+paste from `m4/libevent_openssl.m4`.  Surprisingly to me, a `break` outside of any loop does not seem to be treated as an error.
2023-06-07 22:39:46 +02:00
Michael Davidsaver
7cd51ae1dd Add CI tests which require SSL libraries 2023-06-07 11:10:14 -07:00
Michael Davidsaver
9ce6ae78af Add option to auto-detect OpenSSL and MbedTLS 2023-06-07 11:10:14 -07:00
Michael Davidsaver
71848a237e libevent_mbedtls.m4 remove extraneous break
Maybe a leftover or copy+paste from a for loop
in libevent_openssl.m4 ?
2023-06-06 12:41:53 -07:00
Diogo Teles Sant'Anna
bca26524fc
Create Security Policy (#1462)
I've created the SECURITY.md file following a GitHub's template and considering the report vulnerability through security advisory, which is a handy new GitHub feature (but it's still in beta and has to be enabled).

Closes #1461
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2023-05-25 07:05:28 +02:00
Leo Zhang
1418e793ad build: fix some new warnings
/opensource/libevent/sample/ws-chat-server.c:253:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
2023-05-25 07:00:35 +02:00
Azat Khuzhin
283a371f51 cmake: log when CMAKE_DEBUG_POSTFIX/CMAKE_BUILD_TYPE is changed 2023-05-23 21:46:14 +02:00
Azat Khuzhin
2112c3969a autotools: fix generating pkg-config files (by substituting CMAKE_DEBUG_POSTFIX)
Fixes: #1459
2023-05-22 08:48:06 +02:00
Daniel Engberg
4effaee523 cmake: Fix .pc files when building in Release mode
Don't define CMAKE_DEBUG_POSTFIX as this breaks Release builds, only apply when doing debug builds.
2023-05-22 08:14:42 +02:00
Azat Khuzhin
abc114e3c8 Bump default version when git tag is incorrect
Fixes: #1457
2023-05-21 12:49:34 +02:00
Azat Khuzhin
1c06b68fee Add a note about the last number in NUMERIC_VERSION 2023-05-21 10:10:18 +02:00
Azat Khuzhin
fe9dc8f614 Merge branch 'release-2.2-pull' - 2.2.1-alpha (#1380)
* release-2.2-pull:
  Bump version to 2.2.1
  Update ChangeLog and whatsnew for 2.2.1
  Update contributors (for 2.2 release)
release-2.2.1-alpha
2023-05-21 08:54:07 +02:00
Azat Khuzhin
8d1388a372 Bump version to 2.2.1 2023-05-21 08:47:42 +02:00
Azat Khuzhin
4e19e8b455 Update ChangeLog and whatsnew for 2.2.1 2023-05-21 08:47:39 +02:00
Azat Khuzhin
6ce568c38c Update contributors (for 2.2 release) 2023-05-20 18:19:31 +02:00
Azat Khuzhin
13ce3045c7 Merge branch 'changelog-improvements'
* changelog-improvements:
  Generate changelog in a reverse order
  Add PR number into the changelog
  Use authors of the real patches instead of merge commits
  Cleanup changelog.py
2023-05-20 18:19:04 +02:00
Azat Khuzhin
1fb3e6d79e Generate changelog in a reverse order 2023-05-20 18:18:57 +02:00
Azat Khuzhin
8b87ad48cb Add PR number into the changelog 2023-05-20 18:18:57 +02:00
Azat Khuzhin
fb2e1a6919 Use authors of the real patches instead of merge commits 2023-05-20 18:18:57 +02:00
Azat Khuzhin
c2e917d301 Cleanup changelog.py
- Use positional argument for revision range
- Remove unused import
- Add some todos
2023-05-20 18:18:57 +02:00
Azat Khuzhin
2c2ffb8d6e Revert "cmake: Only use relative paths for install DESTINATION option (#1405)"
After rebasing I broke the initial intention of this patch, so it simply
should be reverted.

This reverts commit 81c6b8823c1b58d7837e827bb1098aa5f9e5956b.
2023-05-20 16:00:44 +02:00
Azat Khuzhin
5324e482d0 Merge branch 'ssl-read-pull' - #1454
* ssl-read-pull:
  ssl: add some comments for lack of notify_close
  Drop unused le_ssl_ops::err_is_ok
  More SSL_read() to fill big buffer
  Make bufferevent_set_max_single_read() effect
2023-05-16 21:21:48 +02:00
Azat Khuzhin
49a7ae4c56 ssl: add some comments for lack of notify_close 2023-05-16 21:20:35 +02:00
Azat Khuzhin
e5941b2ce9 Drop unused le_ssl_ops::err_is_ok
It is not used anymore since errors are ignored if some progress had
been done.
2023-05-16 21:20:21 +02:00
Thuan Tran
ef51444f43 More SSL_read() to fill big buffer
Once SSL_read() only get max 16K bytes (one TLS record).
In case of big buffer, should more SSL_read() to fill the buffer.

Using sample https-client to measure max income MBit/s via nload tool.
Note: set bufferevent_set_max_single_read() by 32K and add the chunk
callback to read out each piece of data.

The client sample do https request a data 900KB (the server don't use
Transfer-Encoding: chunked)
- With origin/master: max income is 2.26 MBit/s
  The chunk callback never get a piece of data > 16K.
- With this PR: max income is 2.44 MBit/s
  The chunk callback can get some piece of data 32K or more.
2023-05-16 21:11:54 +02:00
Thuan Tran
4ab3242da1 Make bufferevent_set_max_single_read() effect 2023-05-16 21:11:54 +02:00
Ingo Bauersachs
acfac7ae4a Make dependency paths relocatable
The generated configurations for both CMake and pkg-config included
absolute paths to dependencies (OpenSSL, MbedTLS). This is contrary
to the general CMake advise to create relocatable packages [1].

Additionally, when building both mbedtls and libevent via CMake's
FetchContent in the same project, loading the project would fail with

  INTERFACE_INCLUDE_DIRECTORIES property contains path:
    "/home/user/project/cmake-build/_deps/mbedtls-build/include"
  which is prefixed in the source directory.

The required changes include:
- Adding the outer includes only to the BUILD_INTERFACE solves the
  makes the CMake paths relocatable and thus solves the FetchContent
  problem.
- Updates to libevent_*.pc.in fixes the relocatable issues for
  pkg-config and properly declares currently missing dependencies.
- Using components for linking to OpenSSL (requiring CMake 3.4)
  and MbedTLS. The new MbedTLS target names now match the component
  names of the MbedTLS' CMake project.
- Use the Threads CMake library reference instead of a direct
  reference to support both built-in pthread and -lpthread.

v2 (azat): get back CMAKE_REQUIRED_LIBRARIES

[1] https://cmake.org/cmake/help/v3.25/manual/cmake-packages.7.html#creating-relocatable-packages
2023-05-16 07:46:56 +02:00
Jeremy W. Murphy
81c6b8823c
cmake: Only use relative paths for install DESTINATION option (#1405)
As described in #1404, the explicit use of CMAKE_INSTALL_PREFIX conflicts with using command-line --prefix.

This simply removes all explicit use of CMAKE_INSTALL_PREFIX.

Otherwise this path will be duplicated:

    $ cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=inst ..
    $ DESTDIR=inst ninja install
    ...
    -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/util.h
    -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/ws.h
    ...

Fixes: #1404
Co-authored-by: Jeremy Murphy <jeremymu@blackmagicdesign.com>
2023-05-15 21:07:36 +02:00
Azat Khuzhin
4dee61c02c Merge remote-tracking branch 'upstream/pr/1397' - #1397
* upstream/pr/1397:
  Make sure exported include dirs are correct
  Fix Configure_RPATH()
  Install LibeventConfig.cmake similar to other cmake files
  Use GNUInstallDirs for mapping installation directories
2023-05-14 22:56:02 +02:00
Tobias Mayer
16be768dac Make sure exported include dirs are correct
CMake config files don't need any logic to detect the location of
installed headers or DSOs, because these locations are already
determined at project configuration time. They also don't need
to distinguish between build and install trees, because that is
already handled by the generated `LibeventTargets-*.cmake` files.
2023-05-14 22:43:47 +02:00
Azat Khuzhin
41a7393f3e Fix Configure_RPATH() 2023-05-14 22:43:47 +02:00
Jonathan Ringer
be03bf385b Install LibeventConfig.cmake similar to other cmake files
- Don't destroy cmake file between test case invocations
2023-05-14 22:43:47 +02:00
Jonathan Ringer
1f1593ff27 Use GNUInstallDirs for mapping installation directories 2023-05-14 22:43:47 +02:00
Azat Khuzhin
fe610f2cdc Fix util/mm_calloc_enomem under FreeBSD
It looks like the compiler optimizes this call out with tt_assert():

    (gdb) disas /m test_event_calloc_enomem
    Dump of assembler code for function test_event_calloc_enomem:
       0x0000000000293bb0 <+0>:     push   %rbp
       0x0000000000293bb1 <+1>:     mov    %rsp,%rbp
       0x0000000000293bb4 <+4>:     call   0x29f510 <__error@plt>
       0x0000000000293bb9 <+9>:     movl   $0x0,(%rax)
       0x0000000000293bbf <+15>:    call   0x2990e0 <tinytest_set_test_failed_>
       0x0000000000293bc4 <+20>:    mov    $0x2168e4,%edi
       0x0000000000293bc9 <+25>:    mov    $0x220582,%esi
       0x0000000000293bce <+30>:    mov    $0x20d893,%edx
       0x0000000000293bd3 <+35>:    mov    $0x53a,%ecx
       0x0000000000293bd8 <+40>:    xor    %eax,%eax
       0x0000000000293bda <+42>:    call   0x29f3b0 <printf@plt>
       0x0000000000293bdf <+47>:    mov    $0x20da72,%edi
       0x0000000000293be4 <+52>:    mov    $0x20f731,%esi
       0x0000000000293be9 <+57>:    xor    %eax,%eax
       0x0000000000293beb <+59>:    pop    %rbp
       0x0000000000293bec <+60>:    jmp    0x29f3b0 <printf@plt>

While with tt_ptr_op() it does not:

    (gdb) disas /m test_event_calloc_enomem
    Dump of assembler code for function test_event_calloc_enomem:
       0x0000000000293bd0 <+0>:     push   %rbp
       0x0000000000293bd1 <+1>:     mov    %rsp,%rbp
       0x0000000000293bd4 <+4>:     push   %rbx
       0x0000000000293bd5 <+5>:     push   %rax
       0x0000000000293bd6 <+6>:     call   0x29f610 <__error@plt>
       0x0000000000293bdb <+11>:    movl   $0x0,(%rax)
       0x0000000000293be1 <+17>:    mov    $0xffffffffffffffff,%rdi
       0x0000000000293be8 <+24>:    mov    $0xffffffffffffffff,%rsi
       0x0000000000293bef <+31>:    call   0x2a01c0 <calloc@plt>
       0x0000000000293bf4 <+36>:    test   %rax,%rax
       0x0000000000293bf7 <+39>:    je     0x293c2b <test_event_calloc_enomem+91>
2023-05-14 22:35:53 +02:00
Azat Khuzhin
13f5552336 test: add missing include of arpa/inet.h for ntohs in regress_ws.c
This will fix one warning in FreeBSD
2023-05-14 22:31:02 +02:00
Azat Khuzhin
1f006637ec Merge branch 'build/osx-fixes'
* build/osx-fixes:
  Suppress -Wmacro-redefined for htonll/ntohll in OSX
  Fix -Wtautological-constant-out-of-range-compare in regress_http under OSX
2023-05-14 22:03:26 +02:00
Azat Khuzhin
6eba967e1c Suppress -Wmacro-redefined for htonll/ntohll in OSX
OSX:

    test/regress_ws.c:61:9: warning: 'htonll' macro redefined [-Wmacro-redefined]
    #define htonll(x)    \
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:141:9: note: previous definition is here
    #define htonll(x)       __DARWIN_OSSwapInt64(x)
            ^
    test/regress_ws.c:65:9: warning: 'ntohll' macro redefined [-Wmacro-redefined]
    #define ntohll(x) htonll(x)
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:140:9: note: previous definition is here
    #define ntohll(x)       __DARWIN_OSSwapInt64(x)
            ^
2023-05-14 22:01:18 +02:00
Azat Khuzhin
5f1fc92b13 Fix -Wtautological-constant-out-of-range-compare in regress_http under OSX
compiler warning:

    test/regress_http.c:968:38: warning: result of comparison of constant 65536 with expression of type 'enum evhttp_cmd_type' is always true [-Wtautological-constant-out-of-range-compare]
            if (evhttp_request_get_command(req) != EVHTTP_REQ_CUSTOM) {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~
2023-05-14 21:55:43 +02:00
Dmitry Antipov
d19690980d Silence weird GCC warning about an uninitialized variable
For the CMake release build with -DEVENT__ENABLE_GCC_WARNINGS=ON
and -DEVENT__DISABLE_MM_REPLACEMENT=ON, GCC version 11 and 12 may
complain about possibly uninitialized variable:

In function ‘event_debug_assert_not_added_’,
    inlined from ‘event_assign’ at event.c:2184:2,
    inlined from ‘event_new’ at event.c:2276:6:
cc1: error: ‘ev’ may be used uninitialized [-Werror=maybe-uninitialized]
event.c: In function ‘event_new’:
event.c:361:13: note: by argument 1 of type ‘const struct event *’ to  event_debug_assert_not_added_.part.0’ declared here
  361 | static void event_debug_assert_not_added_(const struct event *ev)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This warning is most likely a false positive and can be silenced
by explicitly disabling inlining for 'event_assign()'.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
2023-05-14 20:42:19 +02:00
Azat Khuzhin
73037f88f9 Ignore any archives (since you may use separate build dir for 'make dist') 2023-05-14 20:32:50 +02:00
Azat Khuzhin
e8cbe7b6e1 Merge branch 'ssl/fix-partial-read' - #1451
* ssl/fix-partial-read:
  ssl: do not triger EOF if some data had been successfully read
  ssl: rename err_is_ok to handshake_is_ok (internal API)
2023-05-14 20:04:44 +02:00
Azat Khuzhin
7652cf4068 ssl: do not triger EOF if some data had been successfully read
Previously in case when evbuffer_reserve_space() returns > 1, but
it was able to read only 1 IO vector, it will try to read the next one,
got 0 (EOF for mbedTLS or SSL_ERROR_ZERO_RETURN for OpenSSL) and will
trigger EOF, while instead, it should trigger EV_READ w/o EOF and only
after EOF.
2023-05-14 16:53:13 +02:00
Azat Khuzhin
6375dcb46d ssl: rename err_is_ok to handshake_is_ok (internal API) 2023-05-14 16:49:18 +02:00
liaotonglang
d06e573c60 style fix: use tab for indent 2023-05-05 22:42:43 +02:00
fanquake
bdb343e180 ci: use newer actions/x versions for master jobs
Now that the jobs are running again, a number of deprecation warnings
have surfaced
https://github.com/libevent/libevent/actions/runs/4876367881:
```bash
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2.0.0.
```

Looks like the most straightforward thing todo here is just use the
newer version of the checkout action.

Also move to the v1 tag for the coveralls job, rather than a pinned,
much older version (the latest release is 1.2.5, https://github.com/coverallsapp/github-action/releases).

Same again for actions/cache.
2023-05-04 21:21:40 +02:00
fanquake
211736697b ci: use OpenBSD 7.2 over 7.1
In the most recent CI run, all the OpenBSD CI jobs failed, i.e
https://github.com/libevent/libevent/actions/runs/4876367885/jobs/8699759831,
this seems to be due to the fact that packages for 7.1 have been removed
from https://cdn.openbsd.org/pub/OpenBSD/ (only has 7.2 & 7.3):
```bash
  Config file: openbsd-7.1.conf
  https://cdn.openbsd.org/pub/OpenBSD/7.1/packages/amd64/: no such dir
  Can't find rsync-3.2.3p0
  Couldn't install rsync-3.2.3p0
  exec shell: bash run.sh showDebugInfo
```

Switch to using 7.2, which is available, so that the CI will run.
2023-05-04 21:20:23 +02:00
fanquake
60ad22d47d actions: use supported version of Ubuntu
It looks like these jobs are failing to run, because support for
ubuntu-18.04 has been removed entirely, see:
https://github.com/actions/runner-images/issues/6002.

Migrate to ubuntu-20.04.
2023-05-03 22:43:17 +02:00
fanquake
75208132d5
doc: minor cleanups following #1441 (#1442)
Also fixes 1 broken link (apologies).
2023-04-20 23:33:22 +03:00
Azat Khuzhin
612a74c766
Merge pull request #1441 from fanquake/autoconf_doc_updates
doc: minor autoconf/formatting improvements
2023-04-17 21:19:58 +02:00
fanquake
ac69410e1b
doc: mark Autotools as deprecated in building.md
Re-arrange so CMake is mentioned first.
Formatting improvements.
2023-04-17 14:42:59 +01:00