1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (rb_fd_select): the all three fd_sets must be long enough for

select.  fixed: [ruby-talk:149059]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-07-23 02:46:41 +00:00
parent 6524f34a26
commit 80914a2666
3 changed files with 30 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Sat Jul 23 11:46:30 2005 Tanaka Akira <akr@m17n.org>
* eval.c (rb_fd_select): the all three fd_sets must be long enough for
select. fixed: [ruby-talk:149059]
Sat Jul 23 10:01:41 2005 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Jul 23 10:01:41 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_vsprintf, rb_sprintf): new functions return new String, * sprintf.c (rb_vsprintf, rb_sprintf): new functions return new String,

26
eval.c
View file

@ -9871,8 +9871,8 @@ rb_fd_zero(fds)
} }
} }
void static void
rb_fd_set(n, fds) rb_fd_resize(n, fds)
int n; int n;
rb_fdset_t *fds; rb_fdset_t *fds;
{ {
@ -9887,6 +9887,14 @@ rb_fd_set(n, fds)
memset((char *)fds->fdset + o, 0, m - o); memset((char *)fds->fdset + o, 0, m - o);
} }
if (n >= fds->maxfd) fds->maxfd = n + 1; if (n >= fds->maxfd) fds->maxfd = n + 1;
}
void
rb_fd_set(n, fds)
int n;
rb_fdset_t *fds;
{
rb_fd_resize(n, fds);
FD_SET(n, fds->fdset); FD_SET(n, fds->fdset);
} }
@ -9922,6 +9930,18 @@ rb_fd_copy(dst, src, max)
memcpy(dst->fdset, src, size); memcpy(dst->fdset, src, size);
} }
int
rb_fd_select(n, readfds, writefds, exceptfds, timeout)
int n;
rb_fdset_t *readfds, *writefds, *exceptfds;
struct timeval *timeout;
{
rb_fd_resize(n - 1, readfds);
rb_fd_resize(n - 1, writefds);
rb_fd_resize(n - 1, exceptfds);
return select(n, rb_fd_ptr(readfds), rb_fd_ptr(writefds), rb_fd_ptr(exceptfds), timeout);
}
#undef FD_ZERO #undef FD_ZERO
#undef FD_SET #undef FD_SET
#undef FD_CLR #undef FD_CLR
@ -10786,7 +10806,7 @@ rb_thread_schedule()
delay_ptr = &delay_tv; delay_ptr = &delay_tv;
} }
n = select(max+1, rb_fd_ptr(&readfds), rb_fd_ptr(&writefds), rb_fd_ptr(&exceptfds), delay_ptr); n = rb_fd_select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
if (n < 0) { if (n < 0) {
int e = errno; int e = errno;

View file

@ -168,6 +168,7 @@ void rb_fd_set _((int, rb_fdset_t *));
void rb_fd_clr _((int, rb_fdset_t *)); void rb_fd_clr _((int, rb_fdset_t *));
int rb_fd_isset _((int, const 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 *, const fd_set *, int));
int rb_fd_select _((int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *));
#define rb_fd_ptr(f) ((f)->fdset) #define rb_fd_ptr(f) ((f)->fdset)
#define rb_fd_max(f) ((f)->maxfd) #define rb_fd_max(f) ((f)->maxfd)
@ -184,6 +185,7 @@ typedef fd_set rb_fdset_t;
#define rb_fd_init(f) FD_ZERO(f) #define rb_fd_init(f) FD_ZERO(f)
#define rb_fd_term(f) (f) #define rb_fd_term(f) (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)
#endif #endif