diff --git a/CMakeLists.txt b/CMakeLists.txt index e449e789..aec52bb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(PIP) set(PIP_MAJOR 3) set(PIP_MINOR 19) -set(PIP_REVISION 1) +set(PIP_REVISION 2) set(PIP_SUFFIX ) set(PIP_COMPANY SHS) set(PIP_DOMAIN org.SHS) diff --git a/libs/io_utils/pibroadcast.cpp b/libs/io_utils/pibroadcast.cpp index 2de77cfe..b3e3087e 100644 --- a/libs/io_utils/pibroadcast.cpp +++ b/libs/io_utils/pibroadcast.cpp @@ -57,7 +57,7 @@ PIBroadcast::PIBroadcast(bool send_only): PIThread(), PIEthUtilBase() { PIBroadcast::~PIBroadcast() { - PIThread::stop(); + PIThread::stopAndWait(); mcast_mutex.unlock(); destroyAll(); } @@ -113,15 +113,14 @@ void PIBroadcast::setLoopbackPortsCount(int count) { void PIBroadcast::destroyAll() { - piForeach(PIEthernet * e, eth_mcast) { - e->stopThreadedRead(); - delete e; + for (auto * e: eth_mcast) { + e->stopAndWait(); + piDeleteSafety(e); } eth_mcast.clear(); if (eth_lo) { - eth_lo->stopThreadedRead(); - delete eth_lo; - eth_lo = 0; + eth_lo->stopAndWait(); + piDeleteSafety(eth_lo); } } @@ -135,7 +134,7 @@ void PIBroadcast::initAll(PIVector al) { al << mcast_address; eth_mcast.clear(); PIEthernet::InterfaceList ifaces = PIEthernet::interfaces(); - piForeachC(PINetworkAddress & a, al) { + for (const auto & a: al) { PIEthernet * ce = 0; // piCout << "mcast try" << a; if (_channels[Multicast]) { @@ -210,7 +209,7 @@ void PIBroadcast::send(const PIByteArray & data) { PIByteArray cd = cryptData(data); if (cd.isEmpty()) return; PIMutexLocker ml(mcast_mutex); - piForeach(PIEthernet * e, eth_mcast) + for (auto * e: eth_mcast) e->send(cd); if (eth_lo) { for (int i = 0; i < lo_pcnt; ++i) { @@ -228,7 +227,7 @@ void PIBroadcast::startRead() { } if (_send_only) return; PIMutexLocker ml(mcast_mutex); - piForeach(PIEthernet * e, eth_mcast) + for (auto * e: eth_mcast) e->startThreadedRead(); if (eth_lo) eth_lo->startThreadedRead(); _started = true; @@ -236,11 +235,11 @@ void PIBroadcast::startRead() { void PIBroadcast::stopRead() { - if (isRunning()) stop(); + if (isRunning()) stopAndWait(); PIMutexLocker ml(mcast_mutex); - piForeach(PIEthernet * e, eth_mcast) - e->stopThreadedRead(); - if (eth_lo) eth_lo->stopThreadedRead(); + for (auto * e: eth_mcast) + e->stopAndWait(); + if (eth_lo) eth_lo->stopAndWait(); _started = false; }