ruby-changes:19357
From: kosaki <ko1@a...>
Date: Sat, 30 Apr 2011 23:11:41 +0900 (JST)
Subject: [ruby-changes:19357] Ruby:r31397 (trunk): * win32/win32.c (rb_w32_fdcopy): New. This can copy even though
kosaki 2011-04-30 23:11:34 +0900 (Sat, 30 Apr 2011) New Revision: 31397 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31397 Log: * win32/win32.c (rb_w32_fdcopy): New. This can copy even though fdset size exceed FD_SETSIZE. * include/ruby/intern.h (rb_fd_copy): use rb_w32_fdcopy() Modified files: trunk/ChangeLog trunk/include/ruby/intern.h trunk/win32/win32.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 31396) +++ include/ruby/intern.h (revision 31397) @@ -269,7 +269,7 @@ 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) *((d)->fdset) = *((s)->fdset) +#define rb_fd_copy(d, s) rb_w32_fdcopy((d), (s)) #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)) #define rb_fd_resize(n, f) ((void)(f)) Index: ChangeLog =================================================================== --- ChangeLog (revision 31396) +++ ChangeLog (revision 31397) @@ -1,3 +1,9 @@ +Sat Apr 30 23:10:15 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * win32/win32.c (rb_w32_fdcopy): New. This can copy even though + fdset size exceed FD_SETSIZE. + * include/ruby/intern.h (rb_fd_copy): use rb_w32_fdcopy() + Sat Apr 30 20:18:43 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * thread.c (do_select): Change arugment type to rb_fdset_t. Index: win32/win32.c =================================================================== --- win32/win32.c (revision 31396) +++ win32/win32.c (revision 31397) @@ -2366,6 +2366,18 @@ return ret; } +void +rb_w32_fdcopy(rb_fdset_t *dst, const rb_fdset_t *src) +{ + if (dst->capa < src->fdset->fd_count) { + dst->capa = (src->fdset->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->fdset->fd_array, + src->fdset->fd_count * sizeof(src->fdset->fd_array[0])); +} + // // Networking trampolines // These are used to avoid socket startup/shutdown overhead in case -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/