From f16290d78d1e7ff8d9eefcf343913eed77ba0768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 2 Nov 2023 10:51:33 +0000 Subject: [PATCH] Prevent assert after fcntl() for O_NONBLOCK There are several asserts after fcntl() in MySQL_Thread::create_new_session_and_client_data_stream() . This commit removes the assert after F_SETFL with O_NONBLOCK. This because it is possible that proxysql is already shutting down. The entry in the error log is kept. --- lib/MySQL_Thread.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 5d6e470beb..93803ea9ca 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2893,8 +2893,12 @@ MySQL_Session * MySQL_Thread::create_new_session_and_client_data_stream(int _fd) int nb = fcntl(_fd, F_SETFL, prevflags | O_NONBLOCK); if (nb == -1) { proxy_error("For FD %d fcntl() returned -1 , previous flags %d , errno %d\n", _fd, prevflags, errno); - if (shutdown == 0) - assert (nb != -1); + // previously we were asserting here. But it is possible that this->shutdown is still 0 during the + // shutdown itself: + // - the current thread is processing connections + // - the signal handler thread is still setting shutdown = 0 + //if (shutdown == 0) + // assert (nb != -1); } } setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(arg_on));