]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/simple: port to osx
authorKefu Chai <kchai@redhat.com>
Sat, 9 Sep 2017 15:08:27 +0000 (23:08 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 16 Sep 2017 02:43:32 +0000 (10:43 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/msg/simple/Accepter.cc

index 5779cc7abec69b8d52c66962e1092d56dbb6799e..6e188c47bc2a5443f0c3fcde773658396d2e1c9d 100644 (file)
@@ -54,7 +54,17 @@ static int set_close_on_exec(int fd)
 
 int Accepter::create_selfpipe(int *pipe_rd, int *pipe_wr) {
   int selfpipe[2];
+#ifdef HAVE_PIPE2
   int ret = ::pipe2(selfpipe, (O_CLOEXEC|O_NONBLOCK));
+#else
+  int ret = ::pipe(selfpipe);
+  if (ret == 0) {
+    for (int i = 0; i < ceph::size(selfpipe); i++) {
+      int f = fcntl(selfpipe[i], F_GETFD);
+      fcntl(selfpipe[i], F_SETFD, f | FD_CLOEXEC | O_NONBLOCK);
+    }
+  }
+#endif
   if (ret < 0 ) {
     lderr(msgr->cct) << __func__ << " unable to create the selfpipe: "
                     << cpp_strerror(errno) << dendl;