|
|
|
|
@@ -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<PINetworkAddress> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|