From 2e4ef165fb295441abf39fc081568e82c8201888 Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Wed, 22 May 2024 21:15:00 -0400 Subject: [PATCH] Clear SSL error queue on shutdown SSL_shutdown can return an error and if it is not cleared it will be left on the thread's error queue since they are thread local causing unrelated connections running on the same thread to be incorrectly terminated. Clear the error queue now if SSL_shutdown returns an error to keep us from impacting other connections. --- lib/mysql_data_stream.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index 2407f3b7e..aa9bcef99 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -433,7 +433,8 @@ MySQL_Data_Stream::~MySQL_Data_Stream() { // other part, we perform a 'quiet' shutdown. For more context see // MYSQL #29579. SSL_set_quiet_shutdown(ssl, 1); - SSL_shutdown(ssl); + if (SSL_shutdown(ssl) < 0) + ERR_clear_error(); } if (ssl) SSL_free(ssl); } @@ -515,7 +516,8 @@ void MySQL_Data_Stream::shut_hard() { // other part, we perform a 'quiet' shutdown. For more context see // MYSQL #29579. SSL_set_quiet_shutdown(ssl, 1); - SSL_shutdown(ssl); + if (SSL_shutdown(ssl) < 0) + ERR_clear_error(); } if (fd >= 0) { shutdown(fd, SHUT_RDWR);