Skip to content

Commit 9993278

Browse files
authored
Merge pull request #393 from rhenium/ky/ssl-macos-send-eprototype
ssl: retry write on EPROTOTYPE on macOS
2 parents ad24cc3 + 2e700c8 commit 9993278

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,11 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts)
16851685
rb_io_wait_readable(fptr->fd);
16861686
continue;
16871687
case SSL_ERROR_SYSCALL:
1688+
#ifdef __APPLE__
1689+
/* See ossl_ssl_write_internal() */
1690+
if (errno == EPROTOTYPE)
1691+
continue;
1692+
#endif
16881693
if (errno) rb_sys_fail(funcname);
16891694
ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
16901695
#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
@@ -1975,6 +1980,16 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
19751980
rb_io_wait_readable(fptr->fd);
19761981
continue;
19771982
case SSL_ERROR_SYSCALL:
1983+
#ifdef __APPLE__
1984+
/*
1985+
* It appears that send syscall can return EPROTOTYPE if the
1986+
* socket is being torn down. Retry to get a proper errno to
1987+
* make the error handling in line with the socket library.
1988+
* [Bug #14713] https://bugs.ruby-lang.org/issues/14713
1989+
*/
1990+
if (errno == EPROTOTYPE)
1991+
continue;
1992+
#endif
19781993
if (errno) rb_sys_fail(0);
19791994
default:
19801995
ossl_raise(eSSLError, "SSL_write");

0 commit comments

Comments
 (0)