From e81895ed16f9254b20efde74e8e1f8b6f461172b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 2 Jul 2024 16:06:47 +0000 Subject: [PATCH] Improve stability in SSL connection getting SSL_ERROR_SYSCALL In case SSL connections get SSL_ERROR_SYSCALL , ERR_get_error() is called to verify if it is possible to perform again a call. --- lib/mysql_data_stream.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index fc1c41589..5bfd876c1 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -698,9 +698,16 @@ int MySQL_Data_Stream::read_from_net() { } else { int ssl_ret=SSL_get_error(ssl, r); proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p, Datastream=%p -- session_id: %u , SSL_get_error(): %d , errno: %d\n", sess, this, sess->thread_session_id, ssl_ret, errno); - if (ssl_ret == SSL_ERROR_SYSCALL && (errno == EINTR || errno == EAGAIN)) { + const int st = ERR_get_error(); + if ( + (ssl_ret == SSL_ERROR_SYSCALL) && + ( + ((errno == EINTR || errno == EAGAIN)) + || (st == 0) + ) + ) { // the read was interrupted, do nothing - proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p, Datastream=%p -- SSL_get_error() is SSL_ERROR_SYSCALL, errno: %d\n", sess, this, errno); + proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p, Datastream=%p -- SSL_get_error() is SSL_ERROR_SYSCALL, errno: %d, ERR_get_error=%d\n", sess, this, errno, st); } else { if (r==0) { // we couldn't read any data if (revents & POLLIN) {