From 0ec57a60af78c82fbdcb36375c812dae33eeca6d Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 22 Feb 2009 04:38:46 +0000 Subject: [PATCH] * ext/socket/init.c (s_recvfrom_nonblock): handles EAGAIN too. * ext/socket/init.c (s_accept_nonblock): ditto, and EPROTO depends on platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/socket/init.c | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cf6214509..5bde437a4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Feb 22 13:38:44 2009 Nobuyoshi Nakada + + * ext/socket/init.c (s_recvfrom_nonblock): handles EAGAIN too. + + * ext/socket/init.c (s_accept_nonblock): ditto, and EPROTO depends + on platforms. + Sun Feb 22 13:03:12 2009 Yuki Sonoda (Yugui) * eval.c (ruby_options): the evaluater now expects iseq instead of tree. diff --git a/ext/socket/init.c b/ext/socket/init.c index 5cf0cbd85c..908268c40c 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -192,8 +192,13 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from) slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)&buf, &alen); if (slen < 0) { - if (errno == EWOULDBLOCK) + switch (errno) { + case EAGAIN: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif rb_sys_fail("recvfrom(2) WANT_READ"); + } rb_sys_fail("recvfrom(2)"); } if (slen < RSTRING_LEN(str)) { @@ -455,8 +460,17 @@ s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen rb_io_set_nonblock(fptr); fd2 = accept(fptr->fd, (struct sockaddr*)sockaddr, len); if (fd2 < 0) { - if (errno == EWOULDBLOCK || errno == ECONNABORTED || errno == EPROTO) + switch (errno) { + case EAGAIN: +#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif + case ECONNABORTED: +#if defined EPROTO + case EPROTO: +#endif rb_sys_fail("accept(2) WANT_READ"); + } rb_sys_fail("accept(2)"); } make_fd_nonblock(fd2);