summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-02 14:13:58 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-02 14:13:58 +0000
commit71c41cf5a5a72e2f7f1f7b7ac1a14213f1fb52cc (patch)
tree8ecc76cc309c3201a4501b047be7223bf3b2a587 /ext/socket/socket.c
parentab6b4786152b663215f05841f7d131d1a7f43db7 (diff)
* io.c (rb_io_wait_readable): handle retryable errors.
* io.c (rb_io_wait_writable): ditto. * ext/socket/socket.c (bsock_send): ditto. * ext/socket/socket.c (s_recvfrom): ditto. * ext/socket/socket.c (s_accept): ditto. * ext/socket/socket.c (udp_send): ditto. * ext/socket/getaddrinfo.c (afdl): made private structures constant. * rubyio.h: prototype; rb_io_wait_readable(), rb_io_wait_writable(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 1c671fd..0825e8d 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -368,9 +368,9 @@ bsock_send(argc, argv, sock)
GetOpenFile(sock, fptr);
f = GetWriteFile(fptr);
fd = fileno(f);
- retry:
rb_thread_fd_writable(fd);
StringValue(mesg);
+ retry:
if (!NIL_P(to)) {
StringValue(to);
n = sendto(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags),
@@ -380,9 +380,7 @@ bsock_send(argc, argv, sock)
n = send(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags));
}
if (n < 0) {
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
+ if (rb_io_wait_writable(fd)) {
goto retry;
}
rb_sys_fail("send(2)");
@@ -438,9 +436,7 @@ s_recvfrom(sock, argc, argv, from)
TRAP_END;
if (slen < 0) {
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
+ if (rb_io_wait_readable(fd)) {
goto retry;
}
rb_sys_fail("recvfrom(2)");
@@ -1166,8 +1162,9 @@ s_accept(klass, fd, sockaddr, len)
rb_gc();
retry = 1;
goto retry;
- case EINTR:
- rb_thread_schedule();
+ default:
+ if (!rb_io_wait_readable(fd)) break;
+ retry = 0;
goto retry;
}
rb_sys_fail(0);
@@ -1431,9 +1428,7 @@ udp_send(argc, argv, sock)
freeaddrinfo(res0);
return INT2FIX(n);
}
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
+ if (rb_io_wait_writable(fileno(f))) {
goto retry;
}
}