From 058aa90f03e18cdf6a2f878f6b5cfe670602ec15 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 5 Sep 2019 14:18:15 -0500 Subject: [PATCH] include/compat: add flags arg to pipe_cloexec This matches pipe(2). Signed-off-by: Sage Weil --- src/common/OutputDataSocket.cc | 2 +- src/common/SubProcess.cc | 6 +++--- src/common/admin_socket.cc | 2 +- src/common/compat.cc | 4 ++-- src/global/signal_handler.cc | 4 ++-- src/include/compat.h | 2 +- src/msg/async/Event.cc | 2 +- src/os/filestore/FileStore.cc | 2 +- src/os/filestore/GenericFileStoreBackend.cc | 2 +- src/rgw/rgw_http_client.cc | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/common/OutputDataSocket.cc b/src/common/OutputDataSocket.cc index 4a5eca72d2f..11d79c63fc5 100644 --- a/src/common/OutputDataSocket.cc +++ b/src/common/OutputDataSocket.cc @@ -119,7 +119,7 @@ OutputDataSocket::~OutputDataSocket() std::string OutputDataSocket::create_shutdown_pipe(int *pipe_rd, int *pipe_wr) { int pipefd[2]; - if (pipe_cloexec(pipefd) < 0) { + if (pipe_cloexec(pipefd, 0) < 0) { int e = errno; ostringstream oss; oss << "OutputDataSocket::create_shutdown_pipe error: " << cpp_strerror(e); diff --git a/src/common/SubProcess.cc b/src/common/SubProcess.cc index b7d6ca4ca81..1faf33e36ee 100644 --- a/src/common/SubProcess.cc +++ b/src/common/SubProcess.cc @@ -146,9 +146,9 @@ int SubProcess::spawn() { int ret = 0; - if ((stdin_op == PIPE && pipe_cloexec(ipipe) == -1) || - (stdout_op == PIPE && pipe_cloexec(opipe) == -1) || - (stderr_op == PIPE && pipe_cloexec(epipe) == -1)) { + if ((stdin_op == PIPE && pipe_cloexec(ipipe, 0) == -1) || + (stdout_op == PIPE && pipe_cloexec(opipe, 0) == -1) || + (stderr_op == PIPE && pipe_cloexec(epipe, 0) == -1)) { ret = -errno; errstr << "pipe failed: " << cpp_strerror(errno); goto fail; diff --git a/src/common/admin_socket.cc b/src/common/admin_socket.cc index 2503ae26573..58075b054e7 100644 --- a/src/common/admin_socket.cc +++ b/src/common/admin_socket.cc @@ -107,7 +107,7 @@ AdminSocket::~AdminSocket() std::string AdminSocket::create_shutdown_pipe(int *pipe_rd, int *pipe_wr) { int pipefd[2]; - if (pipe_cloexec(pipefd) < 0) { + if (pipe_cloexec(pipefd, 0) < 0) { int e = errno; ostringstream oss; oss << "AdminSocket::create_shutdown_pipe error: " << cpp_strerror(e); diff --git a/src/common/compat.cc b/src/common/compat.cc index 3380d1cd031..f681969fff6 100644 --- a/src/common/compat.cc +++ b/src/common/compat.cc @@ -91,10 +91,10 @@ int ceph_posix_fallocate(int fd, off_t offset, off_t len) { #endif } -int pipe_cloexec(int pipefd[2]) +int pipe_cloexec(int pipefd[2], int flags) { #if defined(HAVE_PIPE2) - return pipe2(pipefd, O_CLOEXEC); + return pipe2(pipefd, O_CLOEXEC | flags); #else if (pipe(pipefd) == -1) return -1; diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 56a586d7f01..c3f17f632ec 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -438,7 +438,7 @@ struct SignalHandler : public Thread { SignalHandler() { // create signal pipe - int r = pipe_cloexec(pipefd); + int r = pipe_cloexec(pipefd, 0); ceph_assert(r == 0); r = fcntl(pipefd[0], F_SETFL, O_NONBLOCK); ceph_assert(r == 0); @@ -575,7 +575,7 @@ void SignalHandler::register_handler(int signum, signal_handler_t handler, bool safe_handler *h = new safe_handler; - r = pipe_cloexec(h->pipefd); + r = pipe_cloexec(h->pipefd, 0); ceph_assert(r == 0); r = fcntl(h->pipefd[0], F_SETFL, O_NONBLOCK); ceph_assert(r == 0); diff --git a/src/include/compat.h b/src/include/compat.h index 606e4156288..546bcd49b60 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -190,6 +190,6 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, int ceph_posix_fallocate(int fd, off_t offset, off_t len); -int pipe_cloexec(int pipefd[2]); +int pipe_cloexec(int pipefd[2], int flags); #endif /* !CEPH_COMPAT_H */ diff --git a/src/msg/async/Event.cc b/src/msg/async/Event.cc index 6cd707d6f90..4d2fb339416 100644 --- a/src/msg/async/Event.cc +++ b/src/msg/async/Event.cc @@ -142,7 +142,7 @@ int EventCenter::init(int nevent, unsigned center_id, const std::string &type) return 0; int fds[2]; - if (pipe_cloexec(fds) < 0) { + if (pipe_cloexec(fds, 0) < 0) { int e = errno; lderr(cct) << __func__ << " can't create notify pipe: " << cpp_strerror(e) << dendl; return -e; diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 42d4b313069..9b616406ae3 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -3953,7 +3953,7 @@ int FileStore::_do_copy_range(int from, int to, uint64_t srcoff, uint64_t len, u #ifdef CEPH_HAVE_SPLICE if (backend->has_splice()) { int pipefd[2]; - if (pipe_cloexec(pipefd) < 0) { + if (pipe_cloexec(pipefd, 0) < 0) { int e = errno; derr << " pipe " << " got " << cpp_strerror(e) << dendl; return -e; diff --git a/src/os/filestore/GenericFileStoreBackend.cc b/src/os/filestore/GenericFileStoreBackend.cc index a75d501f11f..89943953a21 100644 --- a/src/os/filestore/GenericFileStoreBackend.cc +++ b/src/os/filestore/GenericFileStoreBackend.cc @@ -204,7 +204,7 @@ int GenericFileStoreBackend::detect_features() int pipefd[2]; loff_t off_in = 0; int r; - if (pipe_cloexec(pipefd) < 0) { + if (pipe_cloexec(pipefd, 0) < 0) { int e = errno; dout(0) << "detect_features: splice pipe met error " << cpp_strerror(e) << dendl; } else { diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index b710771cd7b..291f076e92e 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -1074,7 +1074,7 @@ int RGWHTTPManager::set_request_state(RGWHTTPClient *client, RGWHTTPRequestSetSt int RGWHTTPManager::start() { - if (pipe_cloexec(thread_pipe) < 0) { + if (pipe_cloexec(thread_pipe, 0) < 0) { int e = errno; ldout(cct, 0) << "ERROR: pipe(): " << cpp_strerror(e) << dendl; return -e; -- 2.39.5