From b375151e13742cf1c0c6630d91130035d678ce2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 23 Jan 2023 20:13:54 +0000 Subject: [PATCH] Some debugging code to troubleshoot a crash --- lib/MySQL_Thread.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 64b6f592d..688c91fb8 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -2847,8 +2847,16 @@ MySQL_Session * MySQL_Thread::create_new_session_and_client_data_stream(int _fd) // received from the network. // The only modules that seems to be affected by this issue are Admin, SQLite3 Server // and Clickhouse Server - int nb = fcntl(_fd, F_SETFL, fcntl(_fd, F_GETFL, 0) | O_NONBLOCK); - assert (nb != -1); + int prevflags = fcntl(_fd, F_GETFL, 0); + if (prevflags == -1) { + proxy_error("For FD %d fcntl() returned -1 errno %d\n", _fd, errno); + assert (prevflags != -1); + } + 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); + assert (nb != -1); + } } setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(arg_on));