summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/basicsocket.c2
-rw-r--r--ext/socket/init.c6
-rw-r--r--ext/socket/rubysocket.h1
-rw-r--r--ext/socket/udpsocket.c2
-rw-r--r--ext/socket/unixsocket.c4
5 files changed, 8 insertions, 7 deletions
diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c
index e744ad2..aa99041 100644
--- a/ext/socket/basicsocket.c
+++ b/ext/socket/basicsocket.c
@@ -559,7 +559,7 @@ rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
arg.fd = fptr->fd;
arg.flags = NUM2INT(flags);
while (rb_thread_fd_writable(arg.fd),
- (n = (int)BLOCKING_REGION(func, &arg)) < 0) {
+ (n = (int)BLOCKING_REGION_FD(func, &arg)) < 0) {
if (rb_io_wait_writable(arg.fd)) {
continue;
}
diff --git a/ext/socket/init.c b/ext/socket/init.c
index ebc9031..8fa907f 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -129,7 +129,7 @@ rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
while (rb_io_check_closed(fptr),
rb_thread_wait_fd(arg.fd),
- (slen = BLOCKING_REGION(recvfrom_blocking, &arg)) < 0) {
+ (slen = BLOCKING_REGION_FD(recvfrom_blocking, &arg)) < 0) {
if (!rb_io_wait_readable(fptr->fd)) {
rb_sys_fail("recvfrom(2)");
}
@@ -380,7 +380,7 @@ rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
if (socks) func = socks_connect_blocking;
#endif
for (;;) {
- status = (int)BLOCKING_REGION(func, &arg);
+ status = (int)BLOCKING_REGION_FD(func, &arg);
if (status < 0) {
switch (errno) {
case EAGAIN:
@@ -515,7 +515,7 @@ rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
arg.len = len;
retry:
rb_thread_wait_fd(fd);
- fd2 = (int)BLOCKING_REGION(accept_blocking, &arg);
+ fd2 = (int)BLOCKING_REGION_FD(accept_blocking, &arg);
if (fd2 < 0) {
switch (errno) {
case EMFILE:
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 60ac25f..a80c93e 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -197,6 +197,7 @@ int Rconnect();
#include "constdefs.h"
#define BLOCKING_REGION(func, arg) (long)rb_thread_blocking_region((func), (arg), RUBY_UBF_IO, 0)
+#define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
#define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
#define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
diff --git a/ext/socket/udpsocket.c b/ext/socket/udpsocket.c
index b278523..bd62d89 100644
--- a/ext/socket/udpsocket.c
+++ b/ext/socket/udpsocket.c
@@ -177,7 +177,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
arg.to = res->ai_addr;
arg.tolen = res->ai_addrlen;
rb_thread_fd_writable(arg.fd);
- n = (int)BLOCKING_REGION(rsock_sendto_blocking, &arg);
+ n = (int)BLOCKING_REGION_FD(rsock_sendto_blocking, &arg);
if (n >= 0) {
freeaddrinfo(res0);
return INT2FIX(n);
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 25a2c1e..5a8641a 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -249,7 +249,7 @@ unix_send_io(VALUE sock, VALUE val)
arg.fd = fptr->fd;
rb_thread_fd_writable(arg.fd);
- if ((int)BLOCKING_REGION(sendmsg_blocking, &arg) == -1)
+ if ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1)
rb_sys_fail("sendmsg(2)");
return Qnil;
@@ -335,7 +335,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock)
arg.fd = fptr->fd;
rb_thread_wait_fd(arg.fd);
- if ((int)BLOCKING_REGION(recvmsg_blocking, &arg) == -1)
+ if ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1)
rb_sys_fail("recvmsg(2)");
#if FD_PASSING_BY_MSG_CONTROL