aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--thread_pthread.c33
2 files changed, 26 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index fbdcb2b439..ab021af610 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Mar 3 02:30:36 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * 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.
+
Sun Mar 10 09:12:51 2013 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c: described syntax of string form.
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();