From 83acc66df07eaef4e2a197b9b2df806c4d75468c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 2 Apr 2021 09:59:19 +0200 Subject: [PATCH] Closes #3342: Enforce sending the 'initial handshake packet' as soon as it's generated --- lib/MySQL_Thread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index b37ec3ab6b..4bb97ef236 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -5245,6 +5245,12 @@ void MySQL_Thread::listener_handle_new_connection(MySQL_Data_Stream *myds, unsig ioctl_FIONBIO(sess->client_myds->fd, 1); mypolls.add(POLLIN|POLLOUT, sess->client_myds->fd, sess->client_myds, curtime); proxy_debug(PROXY_DEBUG_NET,1,"Session=%p -- Adding client FD %d\n", sess, sess->client_myds->fd); + + // we now enforce sending the 'initial handshake packet' as soon as it's generated. This + // is done to prevent situations in which a client sends a packet *before* receiving + // this 'initial handshake', leading to invalid state in dataflow, since it will be + // data in both ends of the datastream. For more details see #3342. + sess->writeout(); } else { free(addr); // if we arrive here, accept() failed