From f5af8a1da92e908fefdb17c09e3d2358c9402923 Mon Sep 17 00:00:00 2001 From: andrey Date: Thu, 19 Aug 2021 15:02:30 +0300 Subject: [PATCH] disable autostart pibroadcast --- libs/io_utils/pibroadcast.cpp | 33 ++++++++++++----------------- libs/main/io_devices/piethernet.cpp | 1 + 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/libs/io_utils/pibroadcast.cpp b/libs/io_utils/pibroadcast.cpp index 4fe478f1..d73952ac 100644 --- a/libs/io_utils/pibroadcast.cpp +++ b/libs/io_utils/pibroadcast.cpp @@ -53,8 +53,6 @@ PIBroadcast::PIBroadcast(bool send_only): PIThread(), PIEthUtilBase() { _started = false; _send_only = send_only; _reinit = true; - //initMcast(PIEthernet::allAddresses()); - PIThread::start(3000); } @@ -140,7 +138,6 @@ void PIBroadcast::initAll(PIVector al) { piForeachC (PIEthernet::Address & a, al) { PIEthernet * ce = 0; //piCout << "mcast try" << a; - if (_channels[Multicast]) { ce = new PIEthernet(); ce->setDebug(false); @@ -184,7 +181,6 @@ void PIBroadcast::initAll(PIVector al) { eth_mcast << ce; } } - } if (_channels[Loopback]) { @@ -210,8 +206,7 @@ void PIBroadcast::send(const PIByteArray & data) { PIByteArray cd = cryptData(data); if (cd.isEmpty()) return; PIMutexLocker ml(mcast_mutex); - piForeach (PIEthernet * e, eth_mcast) - e->send(cd); + piForeach (PIEthernet * e, eth_mcast) e->send(cd); if (eth_lo) { for (int i = 0; i < lo_pcnt; ++i) { eth_lo->send("127.0.0.1", lo_port + i, cd); @@ -221,30 +216,30 @@ void PIBroadcast::send(const PIByteArray & data) { void PIBroadcast::startRead() { + if (!isRunning()) { + reinit(); + PIThread::start(3000); + } if (_send_only) return; PIMutexLocker ml(mcast_mutex); - piForeach (PIEthernet * e, eth_mcast) - e->startThreadedRead(); - if (eth_lo) - eth_lo->startThreadedRead(); + piForeach (PIEthernet * e, eth_mcast) e->startThreadedRead(); + if (eth_lo) eth_lo->startThreadedRead(); _started = true; } void PIBroadcast::stopRead() { + if (isRunning()) stop(); PIMutexLocker ml(mcast_mutex); - piForeach (PIEthernet * e, eth_mcast) - e->stopThreadedRead(); - if (eth_lo) - eth_lo->stopThreadedRead(); + piForeach (PIEthernet * e, eth_mcast) e->stopThreadedRead(); + if (eth_lo) eth_lo->stopThreadedRead(); _started = false; } void PIBroadcast::reinit() { initAll(PIEthernet::allAddresses()); - if (_started) - startRead(); + if (_started) startRead(); } @@ -261,8 +256,6 @@ void PIBroadcast::run() { mcast_mutex.lock(); bool r = _reinit, ac = (al != prev_al); mcast_mutex.unlock(); - if (ac || r) - reinit(); - if (ac) - addressesChanged(); + if (ac || r) reinit(); + if (ac) addressesChanged(); } diff --git a/libs/main/io_devices/piethernet.cpp b/libs/main/io_devices/piethernet.cpp index ab46963b..7ef2428e 100644 --- a/libs/main/io_devices/piethernet.cpp +++ b/libs/main/io_devices/piethernet.cpp @@ -993,6 +993,7 @@ void PIEthernet::configureFromVariantDevice(const PIPropertyStorage & d) { PIEthernet::InterfaceList PIEthernet::interfaces() { + //piCout << "PIEthernet::interfaces()"; PIEthernet::InterfaceList il; Interface ci; ci.index = -1;