From: Yui NARUSE Date: 2010-07-05T19:14:43+09:00 Subject: [ruby-dev:41814] [Bug #3515] FreeBSD wrongly raises ECONNRESET on close(2) チケット #3515 が更新されました。 (by Yui NARUSE) FreeBSD のメンテナは knu さんだと思っていました。 で、FreeBSDのこの挙動を知らない人には想像もつかない所で知らない例外が上がるため、 Ruby側としては吸収せざるをえないと思います。 例外のような処理を中断させてしまう方法以外で通知されるならまぁよかったのでしょうけど。 以下のような感じでtrunkにはコミットしようと思います。 1.9.2はどうしましょうか。 diff --git a/ChangeLog b/ChangeLog index 8698b39..8853a0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jul 5 18:33:17 2010 NARUSE, Yui + + * io.c (fptr_finalize): ignore ECONNRESET from close(2). + FreeBSD wrongly sets ECONNRESET on close(2) and it causes + false-negative exceptions. [ruby-dev:41778] + Mon Jul 5 12:32:01 2010 Aaron Patterson * ext/psych/lib/psych/scalar_scanner.rb (parse_string): support diff --git a/io.c b/io.c index 5129a14..4c817b2 100644 --- a/io.c +++ b/io.c @@ -3445,7 +3445,12 @@ fptr_finalize(rb_io_t *fptr, int noraise) /* fptr->fd may be closed even if close fails. * POSIX doesn't specify it. * We assumes it is closed. */ - if (close(fptr->fd) < 0 && NIL_P(err)) + if (close(fptr->fd) < 0 && NIL_P(err) +#ifdef __FreeBSD__ + /* Ignore ECONNRESET of FreeBSD close(2) */ + && errno != ECONNRESET +#endif + ) err = noraise ? Qtrue : INT2NUM(errno); } skip_fd_close: ---------------------------------------- http://redmine.ruby-lang.org/issues/show/3515 ---------------------------------------- http://redmine.ruby-lang.org