curl/CMake
Andy Pan 23fe1a52dc
socketpair: add eventfd and use SOCK_NONBLOCK for socketpair()
Currently, we use `pipe` for `wakeup_create`, which requires ***two***
file descriptors. Furthermore, given its complexity inside, `pipe` is a
bit heavyweight for just a simple event wait/notify mechanism.

`eventfd` would be a more suitable solution for this kind of scenario,
kernel also advocates for developers to use `eventfd` instead of `pipe`
in some simple use cases:

    Applications can use an eventfd file descriptor instead of a pipe
    (see pipe(2) in all cases where a pipe is used simply to signal
    events. The kernel overhead of an eventfd file descriptor is much
    lower than that of a pipe, and only one file descriptor is required
    (versus the two required for a pipe).

This change adds the new backend of `eventfd` for `wakeup_create` and
uses it where available, eliminating the overhead of `pipe`. Also, it
optimizes the `wakeup_create` to eliminate the system calls that make
file descriptors non-blocking by moving the logic of setting
non-blocking flags on file descriptors to `socketpair.c` and using
`SOCK_NONBLOCK` for `socketpair(2)`, `EFD_NONBLOCK` for `eventfd(2)`.

Ref:
https://man7.org/linux/man-pages/man7/pipe.7.html
https://man7.org/linux/man-pages/man2/eventfd.2.html
https://man7.org/linux/man-pages/man2/socketpair.2.html
https://www.gnu.org/software/gnulib/manual/html_node/eventfd.html

Closes #13874
2024-06-04 23:45:36 +02:00
..
Platforms socketpair: add eventfd and use SOCK_NONBLOCK for socketpair() 2024-06-04 23:45:36 +02:00
cmake_uninstall.cmake.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
CMakeConfigurableFile.in copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
curl-config.cmake.in cmake: fix multiple include of CURL package 2023-11-10 18:23:22 +00:00
CurlSymbolHiding.cmake build: untangle CURLDEBUG and DEBUGBUILD macros 2024-05-28 08:12:00 +02:00
CurlTests.c cmake: fix HAVE_IOCTLSOCKET_FIONBIO test with gcc 14 2024-05-11 10:56:37 +02:00
FindBearSSL.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindBrotli.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindCARES.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindGSS.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindLibPSL.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindLibSSH2.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindMbedTLS.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindMSH3.cmake copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
FindNGHTTP2.cmake cmake: whitespace, formatting/tidy-up in comments 2024-05-27 18:07:10 +02:00
FindNGHTTP3.cmake copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
FindNGTCP2.cmake h3: add support for ngtcp2 with AWS-LC builds 2023-10-08 22:35:04 +00:00
FindQUICHE.cmake copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
FindWolfSSL.cmake copyright: update all copyright lines and remove year ranges 2023-01-03 09:19:21 +01:00
FindZstd.cmake cmake: speed up zstd detection 2023-10-27 00:37:34 +00:00
Macros.cmake docs: ascii version of manpage without nroff 2024-03-06 15:55:59 +01:00
OtherTests.cmake cmake: tidy-up OtherTests.cmake 2023-12-19 12:45:24 +00:00
PickyWarnings.cmake cmake: enable -pedantic-errors for clang when CURL_WERROR=ON 2024-04-05 13:05:36 +00:00
Utilities.cmake cmake: fix function description in comment [ci skip] 2024-02-06 22:20:33 +00:00