From f185ceb206422cc8c4b78062de7b32e0eda4ebe0 Mon Sep 17 00:00:00 2001 From: Srivats P Date: Fri, 24 Nov 2023 13:12:35 +0530 Subject: [PATCH] Stop thread if still running in destructor Threads addressed in this commit: - Transmitter (txThread, txStats) - Capturer - EmulXcvr --- server/pcapport.cpp | 7 +++++-- server/pcaptransmitter.cpp | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/pcapport.cpp b/server/pcapport.cpp index 7d8a4cf..6dce776 100644 --- a/server/pcapport.cpp +++ b/server/pcapport.cpp @@ -401,6 +401,8 @@ PcapPort::PortCapturer::PortCapturer(const char *device) PcapPort::PortCapturer::~PortCapturer() { + if (isRunning()) + stop(); capFile_.close(); } @@ -549,7 +551,8 @@ PcapPort::EmulationTransceiver::EmulationTransceiver(const char *device, PcapPort::EmulationTransceiver::~EmulationTransceiver() { - stop(); + if (isRunning()) + stop(); } void PcapPort::EmulationTransceiver::run() @@ -738,7 +741,7 @@ void PcapPort::EmulationTransceiver::stop() QThread::msleep(10); } else { - qWarning("Receive stop requested but is not running!"); + qWarning("Emulation Xcvr stop requested but is not running!"); return; } } diff --git a/server/pcaptransmitter.cpp b/server/pcaptransmitter.cpp index 0f16537..9e122dd 100644 --- a/server/pcaptransmitter.cpp +++ b/server/pcaptransmitter.cpp @@ -34,6 +34,10 @@ PcapTransmitter::PcapTransmitter( PcapTransmitter::~PcapTransmitter() { + if (txThread_.isRunning()) + txThread_.stop(); + if (txStats_.isRunning()) + txStats_.stop(); } bool PcapTransmitter::setRateAccuracy(