From eb025871c466112612c1d7449b2e20bd19e58461 Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Thu, 1 Feb 2018 11:18:13 -0500 Subject: [PATCH] add CLOG_DEBUG for opening/closing TCPSocket objects and fix assert() crash --- src/lib/net/SecureSocket.cpp | 4 ++++ src/lib/net/TCPSocket.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 5c892524..6b9f0d75 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -852,5 +852,9 @@ SecureSocket::showSecureConnectInfo() void SecureSocket::handleTCPConnected(const Event& event, void*) { + if (getSocket() == nullptr) { + LOG((CLOG_DEBUG "disregarding stale connect event")); + return; + } secureConnect(); } diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 18666f3d..b91e5fb6 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -51,6 +51,8 @@ TCPSocket::TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer) throw XSocketCreate(e.what()); } + LOG((CLOG_DEBUG "Opening new socket: %08X", m_socket)); + init(); } @@ -64,6 +66,8 @@ TCPSocket::TCPSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer, { assert(m_socket != NULL); + LOG((CLOG_DEBUG "Opening new socket: %08X", m_socket)); + // socket starts in connected state init(); onConnected(); @@ -97,6 +101,8 @@ TCPSocket::bind(const NetworkAddress& addr) void TCPSocket::close() { + LOG((CLOG_DEBUG "Closing socket: %08X", m_socket)); + // remove ourself from the multiplexer setJob(NULL);