* thread.c (rb_fd_init_copy): new internal api. It provide efficient
copy constructor semantics. * thread.c (do_select): use rb_fd_init_copy(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ddcd5c2939
commit
156ccab796
@ -1,3 +1,9 @@
|
|||||||
|
Sat May 7 22:34:29 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* thread.c (rb_fd_init_copy): new internal api. It provide efficient
|
||||||
|
copy constructor semantics.
|
||||||
|
* thread.c (do_select): use rb_fd_init_copy().
|
||||||
|
|
||||||
Sat May 7 15:18:06 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Sat May 7 15:18:06 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
fix incorrect native_cond_signal call when deadlock was detected.
|
fix incorrect native_cond_signal call when deadlock was detected.
|
||||||
|
|
||||||
|
@ -288,6 +288,7 @@ typedef fd_set rb_fdset_t;
|
|||||||
#define rb_fd_resize(n, f) ((void)(f))
|
#define rb_fd_resize(n, f) ((void)(f))
|
||||||
#define rb_fd_ptr(f) (f)
|
#define rb_fd_ptr(f) (f)
|
||||||
#define rb_fd_init(f) FD_ZERO(f)
|
#define rb_fd_init(f) FD_ZERO(f)
|
||||||
|
#define rb_fd_init_copy(d, s) (*(d) = *(s))
|
||||||
#define rb_fd_term(f) ((void)(f))
|
#define rb_fd_term(f) ((void)(f))
|
||||||
#define rb_fd_max(f) FD_SETSIZE
|
#define rb_fd_max(f) FD_SETSIZE
|
||||||
#define rb_fd_select(n, rfds, wfds, efds, timeout) select((n), (rfds), (wfds), (efds), (timeout))
|
#define rb_fd_select(n, rfds, wfds, efds, timeout) select((n), (rfds), (wfds), (efds), (timeout))
|
||||||
|
37
thread.c
37
thread.c
@ -2327,6 +2327,18 @@ rb_fd_init(volatile rb_fdset_t *fds)
|
|||||||
FD_ZERO(fds->fdset);
|
FD_ZERO(fds->fdset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_fd_init_copy(rb_fdset_t *dst, rb_fdset_t *src)
|
||||||
|
{
|
||||||
|
size_t size = howmany(rb_fd_max(src), NFDBITS) * sizeof(fd_mask);
|
||||||
|
|
||||||
|
if (size < sizeof(fd_set))
|
||||||
|
size = sizeof(fd_set);
|
||||||
|
dst->maxfd = src->maxfd;
|
||||||
|
dst->fdset = xmalloc(size);
|
||||||
|
memcpy(dst->fdset, src->fdset, size);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_fd_term(rb_fdset_t *fds)
|
rb_fd_term(rb_fdset_t *fds)
|
||||||
{
|
{
|
||||||
@ -2432,6 +2444,13 @@ rb_fd_init(volatile rb_fdset_t *set)
|
|||||||
FD_ZERO(set->fdset);
|
FD_ZERO(set->fdset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_fd_init_copy(rb_fdset_t *dst, rb_fdset_t *src)
|
||||||
|
{
|
||||||
|
rb_fd_init(dst);
|
||||||
|
rb_fd_copy(dst, src);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_fd_term(rb_fdset_t *set)
|
rb_fd_term(rb_fdset_t *set)
|
||||||
{
|
{
|
||||||
@ -2523,18 +2542,12 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except,
|
|||||||
timeout = &wait_rest;
|
timeout = &wait_rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read) {
|
if (read)
|
||||||
rb_fd_init(&orig_read);
|
rb_fd_init_copy(&orig_read, read);
|
||||||
rb_fd_copy(&orig_read, read);
|
if (write)
|
||||||
}
|
rb_fd_init_copy(&orig_write, write);
|
||||||
if (write) {
|
if (except)
|
||||||
rb_fd_init(&orig_write);
|
rb_fd_init_copy(&orig_except, except);
|
||||||
rb_fd_copy(&orig_write, write);
|
|
||||||
}
|
|
||||||
if (except) {
|
|
||||||
rb_fd_init(&orig_except);
|
|
||||||
rb_fd_copy(&orig_except, except);
|
|
||||||
}
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
lerrno = 0;
|
lerrno = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user