diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-01 04:56:51 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-01 04:56:51 +0000 |
commit | d98da36b8c4534b87a0277716091f8df9f04f2d7 (patch) | |
tree | 5ba0887eb135e3600d8a505a98219830f78f37b2 /thread.c | |
parent | 9be62b3b1aeb25114c6867f54c5d3a76d9f1db0b (diff) | |
download | ruby-d98da36b8c4534b87a0277716091f8df9f04f2d7.tar.gz |
* thread.c (rb_thread_fd_select): new function to call select
using rb_fdset_t.
* io.c (select_internal): use rb_thread_fd_select instead of
rb_thread_select. based on the patch from Kengo Matsuyama.
[ruby-dev:38221]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -2490,6 +2490,37 @@ rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except, } +int +rb_thread_fd_select(int max, rb_fdset_t * read, rb_fdset_t * write, rb_fdset_t * except, + struct timeval *timeout) +{ + fd_set *r = NULL, *w = NULL, *e = NULL; + + if (!read && !write && !except) { + if (!timeout) { + rb_thread_sleep_forever(); + return 0; + } + rb_thread_wait_for(*timeout); + return 0; + } + + if (read) { + rb_fd_resize(max - 1, read); + r = rb_fd_ptr(read); + } + if (write) { + rb_fd_resize(max - 1, write); + w = rb_fd_ptr(write); + } + if (except) { + rb_fd_resize(max - 1, except); + e = rb_fd_ptr(except); + } + return do_select(max, r, w, e, timeout); +} + + /* * for GC */ |