back to polygonf
git-svn-id: svn://db.shs.com.ru/pip@106 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -371,10 +371,12 @@ bool PIPeer::dataRead(uchar * readed, int size) {
|
||||
if (pi->isNeighbour()) {
|
||||
sba << int(6) << to << from << addr << time;
|
||||
//piCout << "ping from" << from << addr << ", send back to" << pi->name;
|
||||
send_mutex.lock();
|
||||
piForeachC (PeerInfo::Address & a, pi->addresses) {
|
||||
if (eth_send.send(a.address, sba))
|
||||
diag_s.received(sba.size_s());
|
||||
}
|
||||
send_mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,9 +599,11 @@ bool PIPeer::sendToNeighbour(PIPeer::PeerInfo * peer, const PIByteArray & ba) {
|
||||
PIString addr = peer->fastestAddress();
|
||||
//piCout << "[PIPeer] sendToNeighbour" << peer->name << addr << ba.size_s() << "bytes ...";
|
||||
//bool ok = peer->_neth->send(peer->_naddress, ba.data(), ba.size_s());
|
||||
send_mutex.lock();
|
||||
bool ok = eth_send.send(addr, ba);
|
||||
//piCout << "[PIPeer] sendToNeighbour" << (ok ? "ok" : "fail");
|
||||
if (ok) diag_d.sended(ba.size_s());
|
||||
send_mutex.unlock();
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -679,6 +683,7 @@ void PIPeer::pingNeighbours() {
|
||||
piForeach (PeerInfo & p, peers) {
|
||||
//piCout << " ping neighbour" << p.name << p.ping();
|
||||
if (!p.isNeighbour()) continue;
|
||||
send_mutex.lock();
|
||||
piForeach (PeerInfo::Address & a, p.addresses) {
|
||||
//piCout << " address" << a.address << a.wait_ping;
|
||||
if (a.wait_ping) {
|
||||
@@ -693,6 +698,7 @@ void PIPeer::pingNeighbours() {
|
||||
if (eth_send.send(a.address, sba))
|
||||
diag_s.sended(sba.size_s());
|
||||
}
|
||||
send_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,6 +760,7 @@ void PIPeer::reinit() {
|
||||
PIMutexLocker mbl(mc_mutex);
|
||||
PIMutexLocker ethl(eth_mutex);
|
||||
PIMutexLocker pl(peers_mutex);
|
||||
PIMutexLocker sl(send_mutex);
|
||||
initNetwork();
|
||||
eth_send.close();
|
||||
eth_lo.stopThreadedRead();
|
||||
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
PIEthernet::InterfaceList prev_ifaces;
|
||||
PIEthernet eth_send, eth_lo;
|
||||
PITimer timer;
|
||||
PIMutex mc_mutex, eth_mutex, peers_mutex;
|
||||
PIMutex mc_mutex, eth_mutex, peers_mutex, send_mutex;
|
||||
|
||||
PeerInfo self_info;
|
||||
PIVector<PeerInfo> peers;
|
||||
|
||||
@@ -120,6 +120,11 @@ _PITimerImp_Thread::~_PITimerImp_Thread() {
|
||||
|
||||
|
||||
void _PITimerImp_Thread::prepareStart(double interval_ms) {
|
||||
if (interval_ms <= 0.) {
|
||||
piCout << "Achtung! Start PITimer with interval <= 0!";
|
||||
piCout << "Achtung! Parent" << parent;
|
||||
assert(interval_ms > 0.);
|
||||
}
|
||||
st_inc = PISystemTime::fromMilliseconds(interval_ms);
|
||||
st_odt = st_inc * 5;
|
||||
if (st_odt.toSeconds() < 1.) st_odt = PISystemTime::fromSeconds(1.);
|
||||
@@ -302,6 +307,7 @@ _PITimerImp_Pool::Pool::~Pool() {
|
||||
stop();
|
||||
if (!waitForFinish(100))
|
||||
terminate();
|
||||
unlock();
|
||||
timers.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user