From: Kefu Chai Date: Sat, 9 Sep 2017 15:08:27 +0000 (+0800) Subject: msg/simple: port to osx X-Git-Tag: v13.0.1~880^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fbee3159497537280a100611ba44d2bd19aac3fe;p=ceph.git msg/simple: port to osx Signed-off-by: Kefu Chai --- diff --git a/src/msg/simple/Accepter.cc b/src/msg/simple/Accepter.cc index 5779cc7abec..6e188c47bc2 100644 --- a/src/msg/simple/Accepter.cc +++ b/src/msg/simple/Accepter.cc @@ -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;