From 499f158c74b7c455dca08fc30be88cb699ee24c6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 Feb 2011 13:58:20 -0800 Subject: kgio_*read: empty backtrace for ECONNRESET There's nothing a programmer can do about ECONNRESET so just make the exception cheaper to raise so it can still be logged. --- ext/kgio/read_write.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c index 8960035..571eed8 100644 --- a/ext/kgio/read_write.c +++ b/ext/kgio/read_write.c @@ -14,6 +14,7 @@ static VALUE eErrno_EPIPE, eErrno_ECONNRESET; NORETURN(static void raise_empty_bt(VALUE, const char *)); NORETURN(static void my_eof_error(void)); NORETURN(static void wr_sys_fail(const char *)); +NORETURN(static void rd_sys_fail(const char *)); static void raise_empty_bt(VALUE err, const char *msg) { @@ -42,6 +43,15 @@ static void wr_sys_fail(const char *msg) rb_sys_fail(msg); } +static void rd_sys_fail(const char *msg) +{ + if (errno == ECONNRESET) { + errno = 0; + raise_empty_bt(eErrno_ECONNRESET, msg); + } + rb_sys_fail(msg); +} + static void prepare_read(struct io_args *a, int argc, VALUE *argv, VALUE io) { VALUE length; @@ -78,7 +88,7 @@ static int read_check(struct io_args *a, long n, const char *msg, int io_wait) return 0; } } - rb_sys_fail(msg); + rd_sys_fail(msg); } rb_str_set_len(a->buf, n); if (n == 0) -- cgit v1.2.3-24-ge0c7