diff options
author | Samuel Williams <[email protected]> | 2021-06-19 13:47:16 +1200 |
---|---|---|
committer | Kazuki Yamaguchi <[email protected]> | 2021-07-18 17:48:49 +0900 |
commit | 3f1d8a18eac7d775e69b99f761e756f2abb60c12 (patch) | |
tree | 9e85019f55f51ce29d5de6dbf0629f9800f9fde6 /ext/openssl/ossl_ssl.c | |
parent | 397584078006946ec3673d30b4810334c1a5f06d (diff) |
[ruby/openssl] Deprecate and rework old (fd) centric functions
[ky: fixed compatibility with older versions of Ruby]
(cherry picked from commit ruby/ruby@45e65f302b663b2c6ab69df06d3b6f219c1797b2)
https://github.com/ruby/openssl/commit/8d928e0fb9
Diffstat (limited to 'ext/openssl/ossl_ssl.c')
-rw-r--r-- | ext/openssl/ossl_ssl.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index e9e37dc9e3..380b18e71c 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1532,6 +1532,26 @@ no_exception_p(VALUE opts) return 0; } +static void +io_wait_writable(rb_io_t *fptr) +{ +#ifdef HAVE_RB_IO_MAYBE_WAIT + rb_io_maybe_wait_writable(errno, fptr->self, Qnil); +#else + rb_io_wait_writable(fptr->fd); +#endif +} + +static void +io_wait_readable(rb_io_t *fptr) +{ +#ifdef HAVE_RB_IO_MAYBE_WAIT + rb_io_maybe_wait_readable(errno, fptr->self, Qnil); +#else + rb_io_wait_readable(fptr->fd); +#endif +} + static VALUE ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts) { @@ -1566,12 +1586,12 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts) case SSL_ERROR_WANT_WRITE: if (no_exception_p(opts)) { return sym_wait_writable; } write_would_block(nonblock); - rb_io_maybe_wait_writable(errno, fptr->self, Qnil); + io_wait_writable(fptr); continue; case SSL_ERROR_WANT_READ: if (no_exception_p(opts)) { return sym_wait_readable; } read_would_block(nonblock); - rb_io_maybe_wait_readable(errno, fptr->self, Qnil); + io_wait_readable(fptr); continue; case SSL_ERROR_SYSCALL: #ifdef __APPLE__ @@ -1749,12 +1769,12 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock) case SSL_ERROR_WANT_WRITE: if (no_exception_p(opts)) { return sym_wait_writable; } write_would_block(nonblock); - rb_io_maybe_wait_writable(errno, fptr->self, Qnil); + io_wait_writable(fptr); continue; case SSL_ERROR_WANT_READ: if (no_exception_p(opts)) { return sym_wait_readable; } read_would_block(nonblock); - rb_io_maybe_wait_readable(errno, fptr->self, Qnil); + io_wait_readable(fptr); continue; case SSL_ERROR_SYSCALL: if (!ERR_peek_error()) { @@ -1865,12 +1885,12 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts) case SSL_ERROR_WANT_WRITE: if (no_exception_p(opts)) { return sym_wait_writable; } write_would_block(nonblock); - rb_io_maybe_wait_writable(errno, fptr->self, Qnil); + io_wait_writable(fptr); continue; case SSL_ERROR_WANT_READ: if (no_exception_p(opts)) { return sym_wait_readable; } read_would_block(nonblock); - rb_io_maybe_wait_readable(errno, fptr->self, Qnil); + io_wait_readable(fptr); continue; case SSL_ERROR_SYSCALL: #ifdef __APPLE__ |