From: Sage Weil Date: Thu, 5 Sep 2019 19:18:15 +0000 (-0500) Subject: include/compat: add flags arg to pipe_cloexec X-Git-Tag: v15.1.0~1323^2~49 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=058aa90f03e18cdf6a2f878f6b5cfe670602ec15;p=ceph.git include/compat: add flags arg to pipe_cloexec This matches pipe(2). Signed-off-by: Sage Weil --- diff --git a/src/common/OutputDataSocket.cc b/src/common/OutputDataSocket.cc index 4a5eca72d2f5..11d79c63fc5b 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 b7d6ca4ca818..1faf33e36eee 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 2503ae265732..58075b054e72 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 3380d1cd031c..f681969fff6a 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 56a586d7f018..c3f17f632ec3 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 606e41562888..546bcd49b603 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 6cd707d6f901..4d2fb3394162 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 42d4b3130693..9b616406ae36 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 a75d501f11fc..89943953a210 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 b710771cd7bb..291f076e92ea 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;