* 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
This commit is contained in:
kosaki 2013-03-10 03:59:07 +00:00
Родитель e2e374e45a
Коммит 5cebbe8f9b
2 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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();