about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-01 13:58:20 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-01 13:58:20 -0800
commit499f158c74b7c455dca08fc30be88cb699ee24c6 (patch)
tree7dc25822e77a680bcf41d579af26b6698181ed5c
parent36f69750cd69cbf892580da04be6675e23d92f6f (diff)
downloadkgio-499f158c74b7c455dca08fc30be88cb699ee24c6.tar.gz
There's nothing a programmer can do about ECONNRESET
so just make the exception cheaper to raise so it
can still be logged.
-rw-r--r--ext/kgio/read_write.c12
1 files changed, 11 insertions, 1 deletions
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)