]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/compat: add flags arg to pipe_cloexec
authorSage Weil <sage@redhat.com>
Thu, 5 Sep 2019 19:18:15 +0000 (14:18 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Oct 2019 21:30:52 +0000 (16:30 -0500)
This matches pipe(2).

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/OutputDataSocket.cc
src/common/SubProcess.cc
src/common/admin_socket.cc
src/common/compat.cc
src/global/signal_handler.cc
src/include/compat.h
src/msg/async/Event.cc
src/os/filestore/FileStore.cc
src/os/filestore/GenericFileStoreBackend.cc
src/rgw/rgw_http_client.cc

index 4a5eca72d2f574a800e0607edd6f5d958e12754a..11d79c63fc5be15febeee8aedffd05ac28771154 100644 (file)
@@ -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);
index b7d6ca4ca818158d872158667ccc1c420d2ef3cd..1faf33e36eeeb45af57068185edeacc2407bd10a 100644 (file)
@@ -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;
index 2503ae26573260bbb1d9e7f651809e8cf2533609..58075b054e72ad0f60fa520919ce0af0f5273caf 100644 (file)
@@ -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);
index 3380d1cd031c6bbb1d1547559ed65e30fd6f9873..f681969fff6a06e43384262a611112a39446aa80 100644 (file)
@@ -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;
index 56a586d7f018bc22d8ed3ad3d501ff2f06983f64..c3f17f632ec38fe88955004afff224a57f3cdc80 100644 (file)
@@ -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);
index 606e4156288823f68785a1e1b597450e1f46c677..546bcd49b6038c503b24d3606b5acc10c2f8991b 100644 (file)
@@ -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 */
index 6cd707d6f901168e792cb2d4d560650bce7ccb9c..4d2fb33941623e36a192892770a43c7b98081ca9 100644 (file)
@@ -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;
index 42d4b3130693b2445792c74d2e361bd3a6de17db..9b616406ae36c7429d76d6c0563ad33671487b94 100644 (file)
@@ -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;
index a75d501f11fc2cd8f962e243fec733ecc6c0a3ab..89943953a210bbf7dd2b364db83f3171d9b5d538 100644 (file)
@@ -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 {
index b710771cd7bbb8866f07b6cc5f7c67faee966953..291f076e92ea09deb14d4137a0ccda74a0cee884 100644 (file)
@@ -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;