108 Commits

Author SHA1 Message Date
Cœur
eec47a6710
Fix typos (#1634) 2024-04-30 09:59:58 +02:00
Hennadii Stepanov
71d41cdf37 build: Add Iphlpapi to Libs.private in *.pc files on Windows
It has been required since https://github.com/libevent/libevent/pull/923
at least for the `if_nametoindex` call.
2024-04-25 09:44:01 +02:00
Ramon Ortega de Voor
ed35b30feb Fix two compiler errors for unused variable and undefined function
In buffer.c a variable "flags" and a label "done" are defined but
never used if "EVENT__HAVEMMAP" is not defined.

The code does not work on platforms which do not provide
the function `socketpair()`. Introduce EVENT__HAVE_SOCKETPAIR flag
which determines if `socketpair()` or `evutil_ersatz_socketpair()`
is used.
2024-02-19 08:19:24 +01:00
Dave Hart
242f767684 Enable containing package CFLAGS etc.
Add AC_SUBST of LIBEVENT_FLAGS, LIBEVENT_CPPFLAGS, and LIBEVENT_LDFLAGS so they are relayed from the configure command line to the Makefile
2023-06-20 22:45:45 +03:00
Michael Davidsaver
9ce6ae78af Add option to auto-detect OpenSSL and MbedTLS 2023-06-07 11:10:14 -07: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
Azat Khuzhin
1c06b68fee Add a note about the last number in NUMERIC_VERSION 2023-05-21 10:10:18 +02:00
Azat Khuzhin
8d1388a372 Bump version to 2.2.1 2023-05-21 08:47:42 +02:00
Azat Khuzhin
f747a7b93b Prohibit VLA in autotools too 2023-04-04 22:19:07 +02:00
fanquake
e89ddd405b
build: use FORTIFY_SOURCE=3 in autotools build 2023-02-13 16:06:29 +00:00
Dmitry Antipov
0b79a0024f 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>
2023-01-02 17:12:14 +03:00
Dmitry Antipov
1af745d033 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>
2022-11-12 21:14:48 +01:00
Azat Khuzhin
9e346936d4 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.
2022-11-12 19:00:10 +01:00
Dmitry Antipov
117ee9a03f 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.
2022-09-27 22:07:43 +03:00
Dmitry Ilyin
e8313084f9
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.
2022-09-12 22:16:56 +03:00
Dmitry Ilyin
99fd68abde 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
2022-08-09 00:18:10 +02:00
Azat Khuzhin
d881d06260 configure: fix AC_CHECK_FUNCS should use literals
Error

    configure.ac:291: warning: AC_CHECK_FUNCS(getnameinfo
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getprotobynumber
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getservbyname
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_ntop
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_pton
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
2022-07-09 20:29:09 +03:00
Azat Khuzhin
3960449374 Detech -Wno-unused-functions for GCC too
Otherwise build fails [1]:

    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/minheap-internal.h:64:6: error: ‘min_heap_ctor_’ defined but not used [-Werror=unused-function]
     void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
          ^~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:91:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/bufferevent-internal.h:414:1: error: ‘bufferevent_trigger_nolock_’ defined but not used [-Werror=unused-function]
     bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:89:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/evthread-internal.h:140:1: error: ‘EVLOCK_TRY_LOCK_’ defined but not used [-Werror=unused-function]
     EVLOCK_TRY_LOCK_(void *lock)

  [1]: https://github.com/libevent/libevent/runs/7263518180?check_suite_focus=true
2022-07-09 17:17:06 +03:00
Azat Khuzhin
039458892b Fix -Werror for autotools 2022-07-09 17:16:56 +03:00
fanquake
bf3ce77f6c build: only try silence options if they exist
Otherwise GCC will warn. i.e:
```bash
  CCLD     libevent_openssl.la
cc1: note: unrecognized command-line option ‘-Wno-void-pointer-to-enum-cast’
	may have been intended to silence earlier diagnostics
  CCLD     libevent_mbedtls.la
```
2022-06-30 22:06:51 +03:00
cui fliter
1c204d5564
Fix some typos (#1284)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-06-12 23:58:50 +03:00
fanquake
9aa4eb0991
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.
2021-12-01 12:38:55 +08:00
fanquake
082941edf2
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
2021-11-24 14:41:33 +08:00
Azat Khuzhin
7179ceddf0 Add -Wno-void-pointer-to-enum-cast (we use this hack in tests)
Refs: https://reviews.llvm.org/D75758
2021-09-19 13:47:32 +03: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
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
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
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
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
Azat Khuzhin
972289f356 Detect existence of pthread_mutexattr_setprotocol()
Fixes: #1084
2020-08-29 01:15:20 +03:00
okhowang(王沛文)
028385f685 fix build system and add test and cleanup code 2020-07-22 22:53:23 +03:00
fanquake
97a899d9b4
build: remove -Wstrict-aliasing as strict-aliasing is disabled
Note that -Wstrict-aliasing is also include in -Wall.
2020-07-07 13:58:47 +08:00
fanquake
28e3105072
build: move automake options into AM_INIT_AUTOMAKE call 2020-07-07 13:57:35 +08:00
fanquake
0a537b25dd
build: remove commented code from configure.ac 2020-07-07 13:57:34 +08:00
fanquake
0ea7f70744
build: use feature detection when adding compile flags
Rather than trying to detect (potentially very old) GCC versions, just
test whether the flag works with the compiler, and add it to CLFAGS if
so.

-Werror is used to convert unknown flag warnings into errors, and
prevent their addition to CLFAGS.
2020-07-07 13:57:34 +08:00
Pierce Lopez
b6497fa148 build: do not disable deprecation warnings on macOS
this was for using openssl-0.9.8 included in macOS 10.7 - 10.12,
but it is long since time you really should not use that openssl
2020-07-04 16:01:41 -04:00
fanquake
e05ee6d3b5
build: consolidate darwin compile flag additions in configure
This is mostly move-only, apart from some changes to comments.
2020-06-28 19:34:14 +08:00
fanquake
8ac10b6bf7
build: consistently use dnl for comments in configure.ac 2020-06-28 19:34:10 +08:00
fanquake
ff4ec5fdb0
build: remove duplicate -Wredundant-decls 2020-06-26 14:35:41 +08:00
Nick Grifka
83ef3216e4 Add wepoll support to light up the epoll backend on Windows
libevent is lacking a scalable backend on Windows. Let's leverage the wepoll
library until Windows comes up with an epoll/kqueue compete user mode API.

- All regress tests pass for standard wepoll
- These 2 tests fail intermittently for changelist wepoll, so disabling
  changelist wepoll for now
     http/cancel_inactive_server
     http/stream_in
- verify target on Windows runs tests for both wepoll and win32 backends
- wepoll backend preferred over win32 backend
- wepoll version 1.5.6

v2: cleaner backend abstraction. Disallow wepoll on MinGW/Cygwin.
v3: Add wepoll.h to dist
v4: Make sure wepoll source files are excluded from cygwin/mingw builds
v5: Keep win32 as default backend on windows.
v6: Include wepoll in mingw builds. Verified that regress tests pass w/ WEPOLL backend.
v7: Enable wepoll on mingw when building with cmake
v8: Add wepoll testrunner for autotools test target
2020-05-08 23:27:04 +03:00