diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-04-10 06:07:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-04-10 07:01:39 +0000 |
commit | 01949865e2715b487e098dbc60ba3ae7a01a3b54 (patch) | |
tree | 1765648b05f98b73e4af75c79ba9338d15055b03 | |
parent | 59782a15d0be87130934cbecb34ed639be68b44a (diff) | |
download | kgio-01949865e2715b487e098dbc60ba3ae7a01a3b54.tar.gz |
Another thread may have killed the acceptor object.
-rw-r--r-- | ext/kgio/accept.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ext/kgio/accept.c b/ext/kgio/accept.c index c16ba36..df694ad 100644 --- a/ext/kgio/accept.c +++ b/ext/kgio/accept.c @@ -192,6 +192,7 @@ my_accept(struct accept_args *a, int force_nonblock) { int client_fd; VALUE client_io; + int retried = 0; retry: client_fd = thread_accept(a, force_nonblock); @@ -200,6 +201,7 @@ retry: case EAGAIN: if (force_nonblock) return Qnil; + a->fd = my_fileno(a->accept_io); set_blocking_or_block(a->fd); #ifdef ECONNABORTED case ECONNABORTED: @@ -208,6 +210,7 @@ retry: case EPROTO: #endif /* EPROTO */ case EINTR: + a->fd = my_fileno(a->accept_io); goto retry; case ENOMEM: case EMFILE: @@ -215,13 +218,13 @@ retry: #ifdef ENOBUFS case ENOBUFS: #endif /* ENOBUFS */ - errno = 0; - rb_gc(); - client_fd = thread_accept(a, force_nonblock); - } - if (client_fd == -1) { - if (errno == EINTR) + if (!retried) { + retried = 1; + errno = 0; + rb_gc(); goto retry; + } + default: rb_sys_fail("accept"); } } |