From 21efb309e7bd3985647d806b1ef7969c16afba02 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 17 Nov 2000 04:41:19 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 21 +++++++++++++++++++++ bignum.c | 3 ++- eval.c | 41 ++++++++++++++++++++++++++++------------- ext/socket/socket.c | 1 - io.c | 10 ++++++---- 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a07d04b183..0dcdf99ecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Fri Nov 17 02:54:15 2000 Yukihiro Matsumoto + + * io.c (rb_io_close): need not to flush before closing. + + * eval.c (rb_thread_join): should preserve last thread status when + THREAD_TO_KILL. + + * eval.c (rb_thread_stop): ditto. + + * io.c (io_fflush): wrap fflush by TRAP_BEG, TRAP_END. + + * eval.c (rb_eval): method defined within singleton class + definition should behave like singleton method about class + variables. + + * eval.c (is_defined): ditto. + Thu Nov 16 23:06:07 2000 Minero Aoki * lib/net/http.rb: can call {old,new}_implementation any times. @@ -13,6 +30,10 @@ Thu Nov 16 23:06:07 2000 Minero Aoki * lib/net/protocol: detects and catches "break" from block. +Thu Nov 16 16:32:45 2000 Masahiro Tanaka + + * bignum.c (bigdivrem): should have incremented ny first. + Thu Nov 16 14:58:00 2000 Nobuyoshi Nakada * ext/socket/socket.c (sock_new): duplicates file descriptor diff --git a/bignum.c b/bignum.c index 74cd1507dd..2ae471190d 100644 --- a/bignum.c +++ b/bignum.c @@ -903,7 +903,8 @@ bigdivrem(x, y, divp, modp) *modp = rb_big_clone(z); if (dd) { zds = BDIGITS(*modp); - t2 = 0; i = ny; + while (ny-- && !zds[ny]) ; + t2 = 0; i = ++ny; while(i--) { t2 = (t2 | zds[i]) >> dd; q = zds[i]; diff --git a/eval.c b/eval.c index 2a2423e734..c0d47bf4f6 100644 --- a/eval.c +++ b/eval.c @@ -1762,11 +1762,13 @@ is_defined(self, node, buf) break; case NODE_CVAR: - if (rb_cvar_defined(ruby_cbase, node->nd_vid)) { - return "class variable"; + if (!FL_TEST(ruby_cbase, FL_SINGLETON)) { + if (rb_cvar_defined(ruby_cbase, node->nd_vid)) { + return "class variable"; + } + break; } - break; - + /* fall through */ case NODE_CVAR2: if (rb_cvar_defined_singleton(self, node->nd_vid)) { return "class variable"; @@ -2629,9 +2631,11 @@ rb_eval(self, n) break; case NODE_CVAR: - result = rb_cvar_get(ruby_cbase, node->nd_vid); - break; - + if (!FL_TEST(ruby_cbase, FL_SINGLETON)) { + result = rb_cvar_get(ruby_cbase, node->nd_vid); + break; + } + /* fall through */ case NODE_CVAR2: result = rb_cvar_get_singleton(self, node->nd_vid); break; @@ -7216,9 +7220,7 @@ rb_thread_wait_fd(fd) int fd; { if (curr_thread == curr_thread->next) return; -#if 0 - if (ruby_in_compile) return; -#endif + if (curr_thread->status == THREAD_TO_KILL) return; curr_thread->status = THREAD_STOPPED; curr_thread->fd = fd; @@ -7231,6 +7233,7 @@ rb_thread_fd_writable(fd) int fd; { if (curr_thread == curr_thread->next) return Qtrue; + if (curr_thread->status == THREAD_TO_KILL) return Qtrue; curr_thread->status = THREAD_STOPPED; FD_ZERO(&curr_thread->readfds); @@ -7249,7 +7252,8 @@ rb_thread_wait_for(time) { double date; - if (curr_thread == curr_thread->next) { + if (curr_thread == curr_thread->next || + curr_thread->status == THREAD_TO_KILL) { int n; #ifndef linux double d, limit; @@ -7313,7 +7317,8 @@ rb_thread_select(max, read, write, except, timeout) (double)timeout->tv_sec+(double)timeout->tv_usec*1e-6; } - if (curr_thread == curr_thread->next) { /* no other thread */ + if (curr_thread == curr_thread->next || + curr_thread->status == THREAD_TO_KILL) { #ifndef linux struct timeval tv, *tvp = timeout; @@ -7376,16 +7381,20 @@ rb_thread_join(thread) VALUE thread; { rb_thread_t th = rb_thread_check(thread); + enum thread_status last_status = THREAD_RUNNABLE; if (!rb_thread_dead(th)) { if (th == curr_thread) rb_raise(rb_eThreadError, "thread tried to join itself"); if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread) rb_raise(rb_eThreadError, "Thread#join: deadlock - mutual join"); + if (curr_thread->status == THREAD_TO_KILL) + last_status = THREAD_TO_KILL; curr_thread->status = THREAD_STOPPED; curr_thread->join = th; curr_thread->wait_for = WAIT_JOIN; rb_thread_schedule(); + curr_thread->status = last_status; } if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) { @@ -7500,12 +7509,17 @@ rb_thread_pass() VALUE rb_thread_stop() { + enum thread_status last_status = THREAD_RUNNABLE; + rb_thread_critical = 0; if (curr_thread == curr_thread->next) { rb_raise(rb_eThreadError, "stopping only thread\n\tnote: use sleep to stop forever"); } + if (curr_thread->status == THREAD_TO_KILL) + last_status = THREAD_TO_KILL; curr_thread->status = THREAD_STOPPED; rb_thread_schedule(); + curr_thread->status = last_status; return Qnil; } @@ -7547,7 +7561,8 @@ rb_thread_sleep(sec) void rb_thread_sleep_forever() { - if (curr_thread == curr_thread->next) { + if (curr_thread == curr_thread->next || + curr_thread->status == THREAD_TO_KILL) { TRAP_BEG; pause(); TRAP_END; diff --git a/ext/socket/socket.c b/ext/socket/socket.c index e664090cf1..e77e3d609f 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -769,7 +769,6 @@ ruby_connect(fd, sockaddr, len, socks) } } #ifdef HAVE_FCNTL - mode &= ~NONBLOCKING; /* needed? */ fcntl(fd, F_SETFL, mode); #endif return status; diff --git a/io.c b/io.c index 6470788fce..42234bfb6b 100644 --- a/io.c +++ b/io.c @@ -208,8 +208,13 @@ io_fflush(f, path) FILE *f; const char *path; { + int n; + rb_thread_fd_writable(fileno(f)); - if (fflush(f) == EOF) rb_sys_fail(path); + TRAP_BEG; + n = fflush(f); + TRAP_END; + if (n == EOF) rb_sys_fail(path); } /* writing functions */ @@ -1050,9 +1055,6 @@ rb_io_close(io) OpenFile *fptr; fptr = RFILE(io)->fptr; - if (fptr->mode & FMODE_WRITABLE) { - rb_io_flush(io); - } rb_io_fptr_close(fptr); if (fptr->pid) { rb_syswait(fptr->pid); -- cgit v1.2.3