summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 03:59:07 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-10 03:59:07 +0000
commit5cebbe8f9b61edac849d8131e32d4d20105d1164 (patch)
treeb77c56700aaef916df68f8d3795d774a39f0e5cd /thread_pthread.c
parente2e374e45a17056dcddce0827040b4219d3b7c75 (diff)
* thread_pthread.c (set_nonblock): new helper function for set O_NONBLOCK.
* thread_pthread.c (rb_thread_create_timer_thread): set O_NONBLOCK to timer_thread_pipe[0] too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 6e5f53fa67..c67718a362 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1313,6 +1313,23 @@ thread_timer(void *p)
}
static void
+set_nonblock(int fd)
+{
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
+ int oflags;
+ int err;
+
+ oflags = fcntl(fd, F_GETFL);
+ if (oflags == -1)
+ rb_sys_fail(0);
+ oflags |= O_NONBLOCK;
+ err = fcntl(fd, F_SETFL, oflags);
+ if (err == -1)
+ rb_sys_fail(0);
+#endif
+}
+
+static void
rb_thread_create_timer_thread(void)
{
if (!timer_thread_id) {
@@ -1355,20 +1372,8 @@ rb_thread_create_timer_thread(void)
}
rb_update_max_fd(timer_thread_pipe[0]);
rb_update_max_fd(timer_thread_pipe[1]);
-# if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
- {
- int oflags;
- int err;
-
- oflags = fcntl(timer_thread_pipe[1], F_GETFL);
- if (oflags == -1)
- rb_sys_fail(0);
- oflags |= O_NONBLOCK;
- err = fcntl(timer_thread_pipe[1], F_SETFL, oflags);
- if (err == -1)
- rb_sys_fail(0);
- }
-# endif /* defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) */
+ set_nonblock(timer_thread_pipe[0]);
+ set_nonblock(timer_thread_pipe[1]);
/* validate pipe on this process */
timer_thread_pipe_owner_process = getpid();