* thread.c (do_select): remove cygwin specific hack. It's layer
violation and too large hack. * thread.c (cmp_tv, subtract_tv): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
38fe7da841
commit
2cc5eeaf6c
@ -1,3 +1,9 @@
|
|||||||
|
Tue Sep 27 09:44:59 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* thread.c (do_select): remove cygwin specific hack. It's layer
|
||||||
|
violation and too large hack.
|
||||||
|
* thread.c (cmp_tv, subtract_tv): removed.
|
||||||
|
|
||||||
Tue Sep 27 03:50:19 2011 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
|
Tue Sep 27 03:50:19 2011 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
|
||||||
|
|
||||||
* test/rexml/test_sax.rb: add require 'rexml/document'.
|
* test/rexml/test_sax.rb: add require 'rexml/document'.
|
||||||
|
74
thread.c
74
thread.c
@ -2519,33 +2519,6 @@ rb_fd_set(int fd, rb_fdset_t *set)
|
|||||||
#define rb_fd_rcopy(d, s) (*(d) = *(s))
|
#define rb_fd_rcopy(d, s) (*(d) = *(s))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
|
||||||
static long
|
|
||||||
cmp_tv(const struct timeval *a, const struct timeval *b)
|
|
||||||
{
|
|
||||||
long d = (a->tv_sec - b->tv_sec);
|
|
||||||
return (d != 0) ? d : (a->tv_usec - b->tv_usec);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
subtract_tv(struct timeval *rest, const struct timeval *wait)
|
|
||||||
{
|
|
||||||
if (rest->tv_sec < wait->tv_sec) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
while (rest->tv_usec < wait->tv_usec) {
|
|
||||||
if (rest->tv_sec <= wait->tv_sec) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rest->tv_sec -= 1;
|
|
||||||
rest->tv_usec += 1000 * 1000;
|
|
||||||
}
|
|
||||||
rest->tv_sec -= wait->tv_sec;
|
|
||||||
rest->tv_usec -= wait->tv_usec;
|
|
||||||
return rest->tv_sec != 0 || rest->tv_usec != 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except,
|
do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except,
|
||||||
struct timeval *timeout)
|
struct timeval *timeout)
|
||||||
@ -2556,17 +2529,9 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except,
|
|||||||
rb_fdset_t UNINITIALIZED_VAR(orig_except);
|
rb_fdset_t UNINITIALIZED_VAR(orig_except);
|
||||||
double limit = 0;
|
double limit = 0;
|
||||||
struct timeval wait_rest;
|
struct timeval wait_rest;
|
||||||
# if defined(__CYGWIN__)
|
|
||||||
struct timeval start_time;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
# if defined(__CYGWIN__)
|
|
||||||
gettimeofday(&start_time, NULL);
|
|
||||||
limit = (double)start_time.tv_sec + (double)start_time.tv_usec*1e-6;
|
|
||||||
# else
|
|
||||||
limit = timeofday();
|
limit = timeofday();
|
||||||
# endif
|
|
||||||
limit += (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6;
|
limit += (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6;
|
||||||
wait_rest = *timeout;
|
wait_rest = *timeout;
|
||||||
timeout = &wait_rest;
|
timeout = &wait_rest;
|
||||||
@ -2582,44 +2547,7 @@ do_select(int n, rb_fdset_t *read, rb_fdset_t *write, rb_fdset_t *except,
|
|||||||
retry:
|
retry:
|
||||||
lerrno = 0;
|
lerrno = 0;
|
||||||
|
|
||||||
#if defined(__CYGWIN__)
|
#if defined(_WIN32)
|
||||||
{
|
|
||||||
int finish = 0;
|
|
||||||
/* polling duration: 100ms */
|
|
||||||
struct timeval wait_100ms, *wait;
|
|
||||||
wait_100ms.tv_sec = 0;
|
|
||||||
wait_100ms.tv_usec = 100 * 1000; /* 100 ms */
|
|
||||||
|
|
||||||
do {
|
|
||||||
wait = (timeout == 0 || cmp_tv(&wait_100ms, timeout) < 0) ? &wait_100ms : timeout;
|
|
||||||
BLOCKING_REGION({
|
|
||||||
do {
|
|
||||||
result = rb_fd_select(n, read, write, except, wait);
|
|
||||||
if (result < 0) lerrno = errno;
|
|
||||||
if (result != 0) break;
|
|
||||||
|
|
||||||
if (read)
|
|
||||||
rb_fd_dup(read, &orig_read);
|
|
||||||
if (write)
|
|
||||||
rb_fd_dup(write, &orig_write);
|
|
||||||
if (except)
|
|
||||||
rb_fd_dup(except, &orig_except);
|
|
||||||
if (timeout) {
|
|
||||||
struct timeval elapsed;
|
|
||||||
gettimeofday(&elapsed, NULL);
|
|
||||||
subtract_tv(&elapsed, &start_time);
|
|
||||||
gettimeofday(&start_time, NULL);
|
|
||||||
if (!subtract_tv(timeout, &elapsed)) {
|
|
||||||
finish = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (cmp_tv(&wait_100ms, timeout) > 0) wait = timeout;
|
|
||||||
}
|
|
||||||
} while (__th->interrupt_flag == 0);
|
|
||||||
}, 0, 0);
|
|
||||||
} while (result == 0 && !finish);
|
|
||||||
}
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
BLOCKING_REGION({
|
BLOCKING_REGION({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user