git-svn-id: svn://db.shs.com.ru/pip@305 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -135,6 +135,7 @@ PIString PIPeer::PeerInfo::fastestAddress() const {
|
||||
REGISTER_DEVICE(PIPeer)
|
||||
|
||||
PIPeer::PIPeer(const PIString & n): PIIODevice(), eth_tcp_srv(PIEthernet::TCP_Server), eth_tcp_cli(PIEthernet::TCP_Client), diag_s(false), diag_d(false) {
|
||||
//piCout << " PIPeer" << uint(this);
|
||||
destroyed = false;
|
||||
setDebug(false);
|
||||
PIMutexLocker mbl(mc_mutex);
|
||||
@@ -158,6 +159,8 @@ PIPeer::PIPeer(const PIString & n): PIIODevice(), eth_tcp_srv(PIEthernet::TCP_Se
|
||||
|
||||
|
||||
PIPeer::~PIPeer() {
|
||||
//piCout << "~PIPeer" << uint(this);
|
||||
if (destroyed) return;
|
||||
destroyed = true;
|
||||
PIMutexLocker ml(peers_mutex);
|
||||
piForeach (PeerInfo & p, peers)
|
||||
@@ -170,10 +173,14 @@ PIPeer::~PIPeer() {
|
||||
diag_s.stop();
|
||||
diag_d.stop();
|
||||
destroyEths();
|
||||
piForeach (PIEthernet * i, eths_mcast)
|
||||
piForeach (PIEthernet * i, eths_mcast) {
|
||||
if (!i) continue;
|
||||
i->stopThreadedRead();
|
||||
piForeach (PIEthernet * i, eths_bcast)
|
||||
}
|
||||
piForeach (PIEthernet * i, eths_bcast) {
|
||||
if (!i) continue;
|
||||
i->stopThreadedRead();
|
||||
}
|
||||
eth_lo.stopThreadedRead();
|
||||
eth_tcp_srv.stopThreadedRead();
|
||||
eth_tcp_cli.stopThreadedRead();
|
||||
@@ -320,11 +327,13 @@ void PIPeer::initMBcasts(PIStringList al) {
|
||||
|
||||
void PIPeer::destroyEths() {
|
||||
piForeach (PIEthernet * i, eths_traffic) {
|
||||
if (!i) continue;
|
||||
((PIThread*)i)->stop();
|
||||
((PIThread*)i)->waitForFinish(100);
|
||||
i->stopThreadedRead();
|
||||
i->close();
|
||||
delete i;
|
||||
i = 0;
|
||||
}
|
||||
eths_traffic.clear();
|
||||
}
|
||||
@@ -332,26 +341,30 @@ void PIPeer::destroyEths() {
|
||||
|
||||
void PIPeer::destroyMBcasts() {
|
||||
piForeach (PIEthernet * i, eths_mcast) {
|
||||
if (!i) continue;
|
||||
((PIThread*)i)->stop();
|
||||
((PIThread*)i)->waitForFinish(100);
|
||||
i->stopThreadedRead();
|
||||
i->leaveMulticastGroup(_PIPEER_MULTICAST_IP);
|
||||
i->close();
|
||||
delete i;
|
||||
i = 0;
|
||||
}
|
||||
eths_mcast.clear();
|
||||
piForeach (PIEthernet * i, eths_bcast) {
|
||||
if (!i) continue;
|
||||
((PIThread*)i)->stop();
|
||||
((PIThread*)i)->waitForFinish(100);
|
||||
i->stopThreadedRead();
|
||||
i->close();
|
||||
delete i;
|
||||
i = 0;
|
||||
}
|
||||
eths_bcast.clear();
|
||||
((PIThread*)ð_lo)->stop();
|
||||
((PIThread*)ð_lo)->waitForFinish(100);
|
||||
eth_lo.stopThreadedRead();
|
||||
eth_lo.close();
|
||||
eths_mcast.clear();
|
||||
eths_bcast.clear();
|
||||
eth_tcp_srv.stop();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user