diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-02-23 18:51:13 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-02-23 18:56:44 +0100 |
commit | 2e8116149ca45316e7cdd8ed25ea9a130afd0130 (patch) | |
tree | c1b5afd5fdb3470872b7203c0147b48e8d98d0dd /src | |
parent | 1b045b5eef9a930c78819f3badf93b16b1b53d0b (diff) | |
parent | 9bac71350d98580cc7441957fc7c3fa2f4158553 (diff) |
Merge #21250: build: make HAVE_O_CLOEXEC available outside LevelDB (bugfix)
9bac71350d98580cc7441957fc7c3fa2f4158553 build: make HAVE_O_CLOEXEC available outside LevelDB (bugfix) (Sebastian Falbesoner)
584fd91d2d294883e6896dbd64a2176528e94581 init: only use pipe2 if availabile, check in configure (Sebastian Falbesoner)
Pull request description:
The result of the O_CLOEXEC availability check is currently only set in the Makefile and passed to LevelDB (see `LEVELDB_CPPFLAGS_INT` in `src/Makefile.leveldb.include`), but not defined to be used in our codebase. This means that code within the preprocessor conditional `#if HAVE_O_CLOEXEC` was actually never compiled. On the master branch this is currently used for pipe creation in `src/shutdown.cpp`, PR #21007 moves this part to a new module (I found the issue while testing that PR).
The fix is similar to the one in #19803, which solved the same problem for HAVE_FDATASYNC.
In the course of working on the PR it turned out that pipe2 is not available an all platforms, hence a configure check and a corresponding define HAVE_PIPE2 is introduced and used.
The PR can be tested by anyone with a system that has pipe2 and O_CLOEXEC available by putting gibberish into the HAVE_O_CLOEXEC block: on master, everything should compile fine, on PR, the compiler should abort with an error. At least that's my naive way of testing preprocessor logic, happy to hear more sophisticated ways :-)
ACKs for top commit:
laanwj:
Code review ACK 9bac71350d98580cc7441957fc7c3fa2f4158553
Tree-SHA512: aec89faf6ba52b6f014c610ebef7b725d9e967207d58b42a4a71afc9f1268fcb673ecc85b33a2a3debba8105a304dd7edaba4208c5373fcef2ab83e48a170051
Diffstat (limited to 'src')
-rw-r--r-- | src/shutdown.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shutdown.cpp b/src/shutdown.cpp index df5f996022..6a73e0b2d8 100644 --- a/src/shutdown.cpp +++ b/src/shutdown.cpp @@ -32,7 +32,7 @@ static int g_shutdown_pipe[2] = {-1, -1}; bool InitShutdownState() { #ifndef WIN32 -#if HAVE_O_CLOEXEC +#if HAVE_O_CLOEXEC && HAVE_DECL_PIPE2 // If we can, make sure that the file descriptors are closed on exec() // to prevent interference. if (pipe2(g_shutdown_pipe, O_CLOEXEC) != 0) { |