diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-30 15:04:11 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-30 15:04:11 +0000 |
commit | ee7d523631de5755a1b4d8ee1fe8ab8a15edfcde (patch) | |
tree | 499adb60dd741f41fa404179e4c052b4cb278e33 | |
parent | 527be1b25a3192fffa143ef4bb520c9812e8324d (diff) | |
download | ruby-ee7d523631de5755a1b4d8ee1fe8ab8a15edfcde.tar.gz |
* win32/win32.c, include/ruby/intern.h (rb_w32_fd_copy): implement
for rb_thread_select() in thread.c. the use of rb_fd_copy() is
introduced in r33117.
[Bug #5229] [ruby-core:39102]
* thread.c (rb_thread_select): must call rb_fd_init() before using
rb_fdset_t. see the implementations of rb_fd_init()s if you want to
know the reason.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | include/ruby/intern.h | 2 | ||||
-rw-r--r-- | thread.c | 5 | ||||
-rw-r--r-- | win32/win32.c | 16 |
4 files changed, 33 insertions, 1 deletions
@@ -1,3 +1,14 @@ +Tue Aug 30 23:59:36 2011 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c, include/ruby/intern.h (rb_w32_fd_copy): implement + for rb_thread_select() in thread.c. the use of rb_fd_copy() is + introduced in r33117. + [Bug #5229] [ruby-core:39102] + + * thread.c (rb_thread_select): must call rb_fd_init() before using + rb_fdset_t. see the implementations of rb_fd_init()s if you want to + know the reason. + Tue Aug 30 22:34:45 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com> * test/dl/test_callback.rb (test_callback_with_string): prevents diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 27db84e2c6..db595bb7fa 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -286,6 +286,8 @@ void rb_fd_term(rb_fdset_t *); void rb_fd_set(int, rb_fdset_t *); #define rb_fd_clr(n, f) rb_w32_fdclr((n), (f)->fdset) #define rb_fd_isset(n, f) rb_w32_fdisset((n), (f)->fdset) +#define rb_fd_copy(d, s, n) rb_w32_fd_copy((d), (s), (n)) +void rb_w32_fd_copy(rb_fdset_t *, const fd_set *, int); #define rb_fd_dup(d, s) rb_w32_fd_dup((d), (s)) void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src); #define rb_fd_select(n, rfds, wfds, efds, timeout) rb_w32_select((n), (rfds) ? ((rb_fdset_t*)(rfds))->fdset : NULL, (wfds) ? ((rb_fdset_t*)(wfds))->fdset : NULL, (efds) ? ((rb_fdset_t*)(efds))->fdset: NULL, (timeout)) @@ -2686,7 +2686,7 @@ int rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except, struct timeval *timeout) { - rb_fdset_t fdsets[3] = { 0 }; + rb_fdset_t fdsets[3]; rb_fdset_t *rfds = NULL; rb_fdset_t *wfds = NULL; rb_fdset_t *efds = NULL; @@ -2694,14 +2694,17 @@ rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except, if (read) { rfds = &fdsets[0]; + rb_fd_init(rfds); rb_fd_copy(rfds, read, max); } if (write) { wfds = &fdsets[1]; + rb_fd_init(wfds); rb_fd_copy(wfds, write, max); } if (except) { efds = &fdsets[2]; + rb_fd_init(wfds); rb_fd_copy(efds, except, max); } diff --git a/win32/win32.c b/win32/win32.c index 9f86e7c850..5cafb4a416 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2468,6 +2468,21 @@ rb_w32_fdisset(int fd, fd_set *set) /* License: Ruby's */ void +rb_w32_fd_copy(rb_fdset_t *dst, const fd_set *src, int max) +{ + max = min(src->fd_count, max); + if ((UINT)dst->capa < max) { + dst->capa = (src->fd_count / FD_SETSIZE + 1) * FD_SETSIZE; + dst->fdset = xrealloc(dst->fdset, sizeof(unsigned int) + sizeof(SOCKET) * dst->capa); + } + + memcpy(dst->fdset->fd_array, src->fd_array, + max * sizeof(src->fd_array[0])); + dst->fdset->fd_count = src->fd_count; +} + +/* License: Ruby's */ +void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src) { if ((UINT)dst->capa < src->fdset->fd_count) { @@ -2477,6 +2492,7 @@ rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src) memcpy(dst->fdset->fd_array, src->fdset->fd_array, src->fdset->fd_count * sizeof(src->fdset->fd_array[0])); + dst->fdset->fd_count = src->fdset->fd_count; } // |