* 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
This commit is contained in:
nobu 2009-02-22 04:38:46 +00:00
parent 88860a065e
commit 0ec57a60af
2 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,10 @@
Sun Feb 22 13:38:44 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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) <yugui@yugui.jp> Sun Feb 22 13:03:12 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* eval.c (ruby_options): the evaluater now expects iseq instead of tree. * eval.c (ruby_options): the evaluater now expects iseq instead of tree.

View File

@ -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); slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, (struct sockaddr*)&buf, &alen);
if (slen < 0) { 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) WANT_READ");
}
rb_sys_fail("recvfrom(2)"); rb_sys_fail("recvfrom(2)");
} }
if (slen < RSTRING_LEN(str)) { 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); rb_io_set_nonblock(fptr);
fd2 = accept(fptr->fd, (struct sockaddr*)sockaddr, len); fd2 = accept(fptr->fd, (struct sockaddr*)sockaddr, len);
if (fd2 < 0) { 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) WANT_READ");
}
rb_sys_fail("accept(2)"); rb_sys_fail("accept(2)");
} }
make_fd_nonblock(fd2); make_fd_nonblock(fd2);