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();
|
||||
|
||||
Reference in New Issue
Block a user