1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-11-17 04:41:19 +00:00
parent 46608d361a
commit 21efb309e7
5 changed files with 57 additions and 19 deletions

View file

@ -1,3 +1,20 @@
Fri Nov 17 02:54:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <aamine@dp.u-netsurf.ne.jp>
* lib/net/http.rb: can call {old,new}_implementation any times.
@ -13,6 +30,10 @@ Thu Nov 16 23:06:07 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol: detects and catches "break" from block.
Thu Nov 16 16:32:45 2000 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
* bignum.c (bigdivrem): should have incremented ny first.
Thu Nov 16 14:58:00 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/socket/socket.c (sock_new): duplicates file descriptor

View file

@ -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];

41
eval.c
View file

@ -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;

View file

@ -769,7 +769,6 @@ ruby_connect(fd, sockaddr, len, socks)
}
}
#ifdef HAVE_FCNTL
mode &= ~NONBLOCKING; /* needed? */
fcntl(fd, F_SETFL, mode);
#endif
return status;

10
io.c
View file

@ -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);