* io.c (fptr_finalize): close the IO object even if close(2) is failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9541c63080
commit
f20234994e
@ -1,3 +1,7 @@
|
|||||||
|
Thu Dec 25 15:07:22 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* io.c (fptr_finalize): close the IO object even if close(2) is failed.
|
||||||
|
|
||||||
Thu Dec 25 14:51:43 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
Thu Dec 25 14:51:43 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* lib/rdoc/parser.rb (RDoc::Parser.binary?): should read in binary mode.
|
* lib/rdoc/parser.rb (RDoc::Parser.binary?): should read in binary mode.
|
||||||
|
29
io.c
29
io.c
@ -3104,7 +3104,7 @@ finish_writeconv_sync(VALUE arg)
|
|||||||
static void
|
static void
|
||||||
fptr_finalize(rb_io_t *fptr, int noraise)
|
fptr_finalize(rb_io_t *fptr, int noraise)
|
||||||
{
|
{
|
||||||
int ebadf = 0;
|
int close_failure = 0;
|
||||||
if (fptr->writeconv) {
|
if (fptr->writeconv) {
|
||||||
if (fptr->write_lock) {
|
if (fptr->write_lock) {
|
||||||
struct finish_writeconv_arg arg;
|
struct finish_writeconv_arg arg;
|
||||||
@ -3124,29 +3124,22 @@ fptr_finalize(rb_io_t *fptr, int noraise)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fptr->stdio_file) {
|
if (fptr->stdio_file) {
|
||||||
if (fclose(fptr->stdio_file) < 0 && !noraise) {
|
/* fptr->stdio_file is deallocated anyway
|
||||||
/* fptr->stdio_file is deallocated anyway */
|
* even if fclose failed. */
|
||||||
fptr->stdio_file = 0;
|
if (fclose(fptr->stdio_file) < 0)
|
||||||
fptr->fd = -1;
|
close_failure = 1;
|
||||||
rb_sys_fail_path(fptr->pathv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (0 <= fptr->fd) {
|
else if (0 <= fptr->fd) {
|
||||||
if (close(fptr->fd) < 0 && !noraise) {
|
/* fptr->fd may be closed even if close fails.
|
||||||
if (errno != EBADF) {
|
* POSIX doesn't specify it.
|
||||||
/* fptr->fd is still not closed */
|
* We assumes it is closed. */
|
||||||
rb_sys_fail_path(fptr->pathv);
|
if (close(fptr->fd) < 0)
|
||||||
}
|
close_failure = 1;
|
||||||
else {
|
|
||||||
/* fptr->fd is already closed. */
|
|
||||||
ebadf = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fptr->fd = -1;
|
fptr->fd = -1;
|
||||||
fptr->stdio_file = 0;
|
fptr->stdio_file = 0;
|
||||||
fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
|
fptr->mode &= ~(FMODE_READABLE|FMODE_WRITABLE);
|
||||||
if (ebadf) {
|
if (close_failure && !noraise) {
|
||||||
rb_sys_fail_path(fptr->pathv);
|
rb_sys_fail_path(fptr->pathv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user