From 4bca7a3d5c8af4370bf65368e10d1ccf2090d6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 1 Nov 2019 15:00:26 +1100 Subject: [PATCH] Use close_mysql() for failed Monitor connections This can potentially be a solution for issue 2321. If the error during the failed connection creation is not generated by the backend, disconnect closing the TCP connection. --- lib/MySQL_Monitor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index ab373fc4c..9cb9d7024 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -906,7 +906,12 @@ bool MySQL_Monitor_State_Data::create_new_connection() { } if (myrc==NULL) { mysql_error_msg=strdup(mysql_error(mysql)); - mysql_close(mysql); + int myerrno=mysql_errno(mysql); + if (myerrno < 2000) { + mysql_close(mysql); + } else { + close_mysql(mysql); + } mysql = NULL; return false; } else {