1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/openssl] Deprecate and rework old (fd) centric functions

[ky: fixed compatibility with older versions of Ruby]

(cherry picked from commit ruby/ruby@45e65f302b)

https://github.com/ruby/openssl/commit/8d928e0fb9
This commit is contained in:
Samuel Williams 2021-06-19 13:47:16 +12:00 committed by Kazuki Yamaguchi
parent 3975840780
commit 3f1d8a18ea
2 changed files with 28 additions and 6 deletions

View file

@ -26,6 +26,8 @@ if with_config("debug") or enable_config("debug")
$defs.push("-DOSSL_DEBUG")
end
have_func("rb_io_maybe_wait") # Ruby 3.1
Logging::message "=== Checking for system dependent stuff... ===\n"
have_library("nsl", "t_open")
have_library("socket", "socket")

View file

@ -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__