shutdown read side instead of immediately closing socket to allow further read on other end and have a single point of cleanup only

This commit is contained in:
John
2022-03-12 13:01:54 +01:00
parent af6decf96c
commit 2236f165e8
+3 -2
View File
@@ -24,6 +24,8 @@
#ifdef HAVE_PPOLL #ifdef HAVE_PPOLL
# include <poll.h> # include <poll.h>
#endif #endif
#include <sys/types.h>
#include <sys/socket.h>
#include <cstring> #include <cstring>
#include "lib/utils/log.h" #include "lib/utils/log.h"
@@ -184,8 +186,7 @@ void Connection::run() {
} }
if (m_socket) { if (m_socket) {
delete m_socket; shutdown(sockFD, SHUT_RD);
m_socket = nullptr;
} }
time(&m_endedAt); time(&m_endedAt);
logInfo(lf_network, "[%05d] connection closed", getID()); logInfo(lf_network, "[%05d] connection closed", getID());