diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-09 06:12:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-10-09 06:12:54 +0000 |
commit | ca7549b203e07bb32915f57bef2d3a4ef573be96 (patch) | |
tree | 7cbac3441d9fbe49a5f761c7b864780b279c76db /io.c | |
parent | 2ececa42915e74fb33e4c79bdb40f4477649f7a4 (diff) | |
download | ruby-ca7549b203e07bb32915f57bef2d3a4ef573be96.tar.gz |
* gc.c (gc_sweep): also adjust heaps_limits when free unused heap
page. [ruby-core:00526]
* io.c (io_fflush): condition to retry can occur.
* io.c (io_write): returned 0 wrongly if no error occurred.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -277,10 +277,14 @@ io_fflush(f, fptr) int n; rb_thread_fd_writable(fileno(f)); - TRAP_BEG; - n = fflush(f); - TRAP_END; - if (n == EOF) rb_sys_fail(fptr->path); + for (;;) { + TRAP_BEG; + n = fflush(f); + TRAP_END; + if (n != EOF) break; + if (!rb_io_wait_writable(fileno(f))) + rb_sys_fail(fptr->path); + } fptr->mode &= ~FMODE_WBUF; } @@ -374,7 +378,7 @@ io_write(io, str) } } while (--n > 0); #else - for (; (r = fwrite(ptr, 1, n, f)) < n; ptr += r, n -= r) { + while (ptr += (r = fwrite(ptr, 1, n, f)), (n -= r) > 0) { if (ferror(f)) { if (rb_io_wait_writable(fileno(f))) { clearerr(f); @@ -1277,13 +1281,20 @@ fptr_finalize(fptr, fin) if (fptr->f2) { f2 = fileno(fptr->f2); - n2 = fclose(fptr->f2); + while ((n2 = fclose(fptr->f2)) < 0) { + if (!rb_io_wait_writable(f2)) { + e = errno; + break; + } + } fptr->f2 = 0; - if (n2 < 0) e = errno; } if (fptr->f) { f1 = fileno(fptr->f); - n1 = fclose(fptr->f); + while ((n1 = fclose(fptr->f)) < 0) { + if (f2 != -1 || !(fptr->mode & FMODE_WBUF)) break; + if (!rb_io_wait_writable(f1)) break; + } fptr->f = 0; if (n1 < 0 && errno == EBADF) { if (f1 == f2 || !(fptr->mode & FMODE_WBUF)) { |