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