PIDir windows drives support

git-svn-id: svn://db.shs.com.ru/pip@55 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-01 06:41:33 +00:00
parent 071fc76ea3
commit d60e7fad2a
8 changed files with 111 additions and 55 deletions

View File

@@ -122,7 +122,10 @@ PIString PIPeer::PeerInfo::fastestAddress() const {
}
PIPeer::PIPeer(const PIString & name_): PIObject() {
destroyed = false;
setName(name_);
self_info.name = name_;
self_info.dist = 0;
@@ -131,15 +134,16 @@ PIPeer::PIPeer(const PIString & name_): PIObject() {
srand(uint(PISystemTime::current(true).toMicroseconds()));
//id_ = self_info.name + "_" + PIString::fromNumber(rand());
CONNECTU(&timer, tickEvent, this, timerEvent);
prev_ifaces = PIEthernet::interfaces();
initNetwork();
sendSelfInfo();
prev_ifaces = PIEthernet::interfaces();
timer.addDelimiter(5);
timer.start(1000);
}
PIPeer::~PIPeer() {
destroyed = true;
timer.stop();
diag_s.stop();
diag_d.stop();
@@ -148,10 +152,10 @@ PIPeer::~PIPeer() {
i->stopThreadedRead();
piForeach (PIEthernet * i, eths_bcast)
i->stopThreadedRead();
eth_send.close();
eth_lo.stopThreadedRead();
sendSelfRemove();
destroyMBcasts();
eth_send.close();
}
@@ -170,7 +174,6 @@ void PIPeer::timerEvent(void * data, int delim) {
void PIPeer::initEths(PIStringList al) {
PIEthernet * ce;
PIEthernet::InterfaceList il = PIEthernet::interfaces();
const PIEthernet::Interface * cint = 0;
piForeachC (PIString & a, al) {
ce = new PIEthernet();
@@ -183,7 +186,7 @@ void PIPeer::initEths(PIStringList al) {
ce->setReadAddress(a, p);
if (ce->open()) {
eths_traffic << ce;
cint = il.getByAddress(a);
cint = prev_ifaces.getByAddress(a);
self_info.addresses << PeerInfo::Address(ce->path(), cint == 0 ? "255.255.255.0" : cint->netmask);
CONNECTU(ce, threadedReadEvent, this, dataRead);
ce->startThreadedRead();
@@ -204,7 +207,6 @@ void PIPeer::initEths(PIStringList al) {
void PIPeer::initMBcasts(PIStringList al) {
destroyMBcasts();
PIEthernet * ce;
PIEthernet::InterfaceList il = PIEthernet::interfaces();
const PIEthernet::Interface * cint;
PIString nm;
al << _PIPEER_MULTICAST_IP;
@@ -227,7 +229,7 @@ void PIPeer::initMBcasts(PIStringList al) {
ce->setDebug(false);
ce->setName("__S__PIPeer_bcast_eth_" + a);
ce->setParameters(PIEthernet::Broadcast);
cint = il.getByAddress(a);
cint = prev_ifaces.getByAddress(a);
nm = (cint == 0) ? "255.255.255.0" : cint->netmask;
ce->setSendAddress(PIEthernet::getBroadcast(a, nm), _PIPEER_BROADCAST_PORT);
ce->setReadAddress(a, _PIPEER_BROADCAST_PORT);
@@ -240,7 +242,7 @@ void PIPeer::initMBcasts(PIStringList al) {
eth_lo.setDebug(false);
eth_lo.setName("__S__PIPeer_eth_loopback");
eth_lo.setParameters(0);
cint = il.getByAddress("127.0.0.1");
cint = prev_ifaces.getByAddress("127.0.0.1");
for (int p = _PIPEER_LOOPBACK_PORT_S; p <= _PIPEER_LOOPBACK_PORT_E; ++p) {
eth_lo.setReadAddress("127.0.0.1", p);
if (eth_lo.open()) {
@@ -345,6 +347,7 @@ void PIPeer::dtReceived(const PIString & from, const PIByteArray & data) {
bool PIPeer::dataRead(uchar * readed, int size) {
if (destroyed) return true;
if (size < 16) return true;
PIByteArray ba(readed, size), sba, pba;
int type, cnt;
@@ -444,6 +447,7 @@ bool PIPeer::dataRead(uchar * readed, int size) {
bool PIPeer::mbcastRead(uchar * data, int size) {
if (destroyed) return true;
if (size < 8) return true;
int type, dist;
PIByteArray ba(data, size);