From 5cebbe8f9b61edac849d8131e32d4d20105d1164 Mon Sep 17 00:00:00 2001 From: kosaki Date: Sun, 10 Mar 2013 03:59:07 +0000 Subject: * 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 --- ChangeLog | 7 +++++++ thread_pthread.c | 33 +++++++++++++++++++-------------- 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 + + * 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 * 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 @@ -1312,6 +1312,23 @@ thread_timer(void *p) return NULL; } +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) { @@ -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(); -- cgit v1.2.3