aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_ssl.c13
-rw-r--r--ext/socket/ancdata.c4
-rw-r--r--ext/socket/init.c4
-rw-r--r--ext/socket/socket.c2
4 files changed, 14 insertions, 9 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index d5c07d79a9..2ca8ae4529 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -29,6 +29,9 @@ VALUE eSSLError;
VALUE cSSLContext;
VALUE cSSLSocket;
+static VALUE eSSLErrorWaitReadable;
+static VALUE eSSLErrorWaitWritable;
+
#define ossl_sslctx_set_cert(o,v) rb_iv_set((o),"@cert",(v))
#define ossl_sslctx_set_key(o,v) rb_iv_set((o),"@key",(v))
#define ossl_sslctx_set_client_ca(o,v) rb_iv_set((o),"@client_ca",(v))
@@ -1230,8 +1233,7 @@ static void
write_would_block(int nonblock)
{
if (nonblock) {
- VALUE exc = ossl_exc_new(eSSLError, "write would block");
- rb_extend_object(exc, rb_mWaitWritable);
+ VALUE exc = ossl_exc_new(eSSLErrorWaitReadable, "write would block");
rb_exc_raise(exc);
}
}
@@ -1240,8 +1242,7 @@ static void
read_would_block(int nonblock)
{
if (nonblock) {
- VALUE exc = ossl_exc_new(eSSLError, "read would block");
- rb_extend_object(exc, rb_mWaitReadable);
+ VALUE exc = ossl_exc_new(eSSLErrorWaitReadable, "read would block");
rb_exc_raise(exc);
}
}
@@ -1846,6 +1847,10 @@ Init_ossl_ssl()
* Generic error class raised by SSLSocket and SSLContext.
*/
eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError);
+ eSSLErrorWaitReadable = rb_define_class_under(mSSL, "SSLErrorWaitReadable", eSSLError);
+ rb_include_module(eSSLErrorWaitReadable, rb_mWaitReadable);
+ eSSLErrorWaitWritable = rb_define_class_under(mSSL, "SSLErrorWaitWritable", eSSLError);
+ rb_include_module(eSSLErrorWaitWritable, rb_mWaitWritable);
Init_ossl_ssl_session();
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 5ca5bdd3bc..667dd4e95c 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1285,7 +1285,7 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
if (ss == -1) {
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
- rb_mod_sys_fail(rb_mWaitWritable, "sendmsg(2) would block");
+ rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block");
rb_sys_fail("sendmsg(2)");
}
@@ -1600,7 +1600,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
if (ss == -1) {
if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
- rb_mod_sys_fail(rb_mWaitReadable, "recvmsg(2) would block");
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
#if defined(HAVE_ST_MSG_CONTROL)
if (!gc_done && (errno == EMFILE || errno == EMSGSIZE)) {
/*
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 3fda607bee..1360800be9 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -222,7 +222,7 @@ rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- rb_mod_sys_fail(rb_mWaitReadable, "recvfrom(2) would block");
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvfrom(2) would block");
}
rb_sys_fail("recvfrom(2)");
}
@@ -541,7 +541,7 @@ rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, s
#if defined EPROTO
case EPROTO:
#endif
- rb_mod_sys_fail(rb_mWaitReadable, "accept(2) would block");
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "accept(2) would block");
}
rb_sys_fail("accept(2)");
}
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 9b9625485a..3d59b6cc96 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -446,7 +446,7 @@ sock_connect_nonblock(VALUE sock, VALUE addr)
n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr));
if (n < 0) {
if (errno == EINPROGRESS)
- rb_mod_sys_fail(rb_mWaitWritable, "connect(2) would block");
+ rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "connect(2) would block");
rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
}