about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-09-26 02:12:15 +0000
committerEric Wong <normalperson@yhbt.net>2010-09-26 02:12:15 +0000
commit3ca3a23d3e68f62af6d57cf22825b2751c226fff (patch)
treea31c14ab08a742db2a11f7fde888a460a8d5f09b
parent43153f218e14cad3a2c6f4056fcf02dc49dc4b36 (diff)
downloadsleepy_penguin-3ca3a23d3e68f62af6d57cf22825b2751c226fff.tar.gz
There are no FD flags besides FD_CLOEXEC, so
there's no point in making an extra fcntl()
call.
-rw-r--r--ext/sleepy_penguin/epoll.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/ext/sleepy_penguin/epoll.c b/ext/sleepy_penguin/epoll.c
index 14eb860..83f1568 100644
--- a/ext/sleepy_penguin/epoll.c
+++ b/ext/sleepy_penguin/epoll.c
@@ -57,22 +57,15 @@ static struct rb_epoll *ep_get(VALUE self)
  * Don't worry about thread-safety since current Ruby 1.9 won't
  * call this without GVL.
  */
-static int my_epoll_create1(int flags)
+static int epoll_create1(int flags)
 {
-        int set_flags;
         int fd = epoll_create(1024); /* size ignored since 2.6.8 */
 
         if (fd < 0 || flags == 0)
                 return fd;
 
-        if (flags & EPOLL_CLOEXEC) {
-                set_flags = fcntl(fd, F_GETFD);
-                if (set_flags == -1)
-                        goto err;
-                set_flags = fcntl(fd, F_SETFD, set_flags | FD_CLOEXEC);
-                if (set_flags == -1)
-                        goto err;
-        }
+        if ((flags & EPOLL_CLOEXEC) && (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1))
+                goto err;
         return fd;
 err:
         {
@@ -82,7 +75,6 @@ err:
                 return -1;
         }
 }
-#define epoll_create1(flags) my_epoll_create1(flags)
 #endif
 
 static void gcmark(void *ptr)