From e96d46f23052a511f3a1c9e520d64836dfc936eb Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 6 Jan 2020 10:12:41 +0000 Subject: [PATCH] Fix issues reported by valgrind (#2017) * Fix issues with debug statements whilst running exit handlers * Fix issue with `TcpConnection::checkSelfFree()` being called twice Reported in https://github.com/SmingHub/Sming/pull/2007#discussion_r363032722 and #2016 --- Sming/Arch/Host/Components/hostlib/startup.cpp | 3 +++ Sming/Core/Network/TcpConnection.cpp | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sming/Arch/Host/Components/hostlib/startup.cpp b/Sming/Arch/Host/Components/hostlib/startup.cpp index 519a330b96..31db5453de 100644 --- a/Sming/Arch/Host/Components/hostlib/startup.cpp +++ b/Sming/Arch/Host/Components/hostlib/startup.cpp @@ -255,5 +255,8 @@ int main(int argc, char* argv[]) pause(config.exitpause); + // Avoid issues with debug statements whilst running exit handlers + m_setPuts(nullptr); + return exitCode; } diff --git a/Sming/Core/Network/TcpConnection.cpp b/Sming/Core/Network/TcpConnection.cpp index d517ff57ed..d19c46425c 100644 --- a/Sming/Core/Network/TcpConnection.cpp +++ b/Sming/Core/Network/TcpConnection.cpp @@ -499,12 +499,11 @@ err_t TcpConnection::staticOnPoll(void* arg, tcp_pcb* tcp) err_t TcpConnection::internalOnPoll() { - //if (tcp->state != ESTABLISHED) - // return ERR_OK; - sleep++; err_t res = onPoll(); - checkSelfFree(); + if(res == ERR_OK) { + checkSelfFree(); + } debug_tcp_ext("