summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/intern.h5
-rw-r--r--thread.c9
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1cadaaaa46..da7a6a3560 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Apr 30 20:16:53 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * thread.c (rb_fd_copy): Change function argument. Now
+ rb_fd_copy() has fully copy semantics.
+ * include/ruby/intern.h: ditto.
+
Sat Apr 30 20:11:47 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* include/ruby/intern.h (rb_thread_select): mark as deprecated.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index f5339289c6..41e9e963cd 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -250,7 +250,7 @@ void rb_fd_zero(rb_fdset_t *);
void rb_fd_set(int, rb_fdset_t *);
void rb_fd_clr(int, rb_fdset_t *);
int rb_fd_isset(int, const rb_fdset_t *);
-void rb_fd_copy(rb_fdset_t *, const fd_set *, int);
+void rb_fd_copy(rb_fdset_t *dst, const rb_fdset_t *src);
int rb_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
#define rb_fd_ptr(f) ((f)->fdset)
@@ -269,6 +269,7 @@ 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) *((d)->fdset) = *((s)->fdset)
#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))
@@ -282,7 +283,7 @@ typedef fd_set rb_fdset_t;
#define rb_fd_set(n, f) FD_SET((n), (f))
#define rb_fd_clr(n, f) FD_CLR((n), (f))
#define rb_fd_isset(n, f) FD_ISSET((n), (f))
-#define rb_fd_copy(d, s, n) (*(d) = *(s))
+#define rb_fd_copy(d, s) (*(d) = *(s))
#define rb_fd_resize(n, f) ((void)(f))
#define rb_fd_ptr(f) (f)
#define rb_fd_init(f) FD_ZERO(f)
diff --git a/thread.c b/thread.c
index ce84ed5566..ed254e853e 100644
--- a/thread.c
+++ b/thread.c
@@ -2381,12 +2381,13 @@ rb_fd_isset(int n, const rb_fdset_t *fds)
}
void
-rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int max)
+rb_fd_copy(rb_fdset_t *dst, const rb_fdset_t *src)
{
- size_t size = howmany(max, NFDBITS) * sizeof(fd_mask);
+ size_t size = howmany(rb_fd_max(src), NFDBITS) * sizeof(fd_mask);
- if (size < sizeof(fd_set)) size = sizeof(fd_set);
- dst->maxfd = max;
+ if (size < sizeof(fd_set))
+ size = sizeof(fd_set);
+ dst->maxfd = src->maxfd;
dst->fdset = xrealloc(dst->fdset, size);
memcpy(dst->fdset, src, size);
}