git-svn-id: svn://db.shs.com.ru/pip@225 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-08-16 21:22:07 +00:00
parent 590a3be4d4
commit 2a7e45baff
5 changed files with 37 additions and 19 deletions

View File

@@ -77,6 +77,9 @@ bool PIBinaryLog::openDevice() {
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
return false;
}
if (path().isEmpty() && mode_ == WriteOnly) {
setPath(getLogfilePath());
}
if (!file.open(path(), mode_)) {
piCoutObj << "Error: Can't open file" << path();
return false;
@@ -177,8 +180,7 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) {
}
PIString PIBinaryLog::createNewFile() {
if (!file.close()) return PIString();
PIString PIBinaryLog::getLogfilePath() const {
PIDir dir(logDir());
dir.setDir(dir.absolutePath());
if (!dir.isExists()) {
@@ -192,6 +194,12 @@ PIString PIBinaryLog::createNewFile() {
cnpath = npath + "_" + PIString::fromNumber(i) + ".binlog";
i++;
}
return cnpath;
}
PIString PIBinaryLog::createNewFile() {
if (!file.close()) return PIString();
PIString cnpath = getLogfilePath();
if (open(cnpath, PIIODevice::WriteOnly)) {
newFile(file.path());
return file.path();

View File

@@ -283,6 +283,7 @@ private:
BinLogRecord readRecord();
static void parseLog(PIFile *f, BinLogInfo *info, PIVector<BinLogIndex> * index);
void moveIndex(int i);
PIString getLogfilePath() const;
PIVector<BinLogIndex> index;
PIMap<llong, int> index_pos;

View File

@@ -799,13 +799,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
while (pAdapter) {
ci.name = PIString(pAdapter->AdapterName);
ci.index = pAdapter->Index;
ci.address = PIString(pAdapter->IpAddressList.IpAddress.String);
if (ci.address == "0.0.0.0") {
pAdapter = pAdapter->Next;
continue;
}
ci.mac = macFromBytes(PIByteArray(pAdapter->Address, pAdapter->AddressLength));
ci.netmask = PIString(pAdapter->IpAddressList.IpMask.String);
ci.flags = PIEthernet::ifActive | PIEthernet::ifRunning;
//if (ret->ifa_flags & IFF_BROADCAST) ci.flags |= PIEthernet::ifBroadcast;
//if (ret->ifa_flags & IFF_MULTICAST) ci.flags |= PIEthernet::ifMulticast;
@@ -813,11 +807,22 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
if (pAdapter->Type == MIB_IF_TYPE_LOOPBACK) ci.flags |= PIEthernet::ifLoopback;
ci.broadcast.clear();
ci.ptp.clear();
IP_ADDR_STRING * as = &(pAdapter->IpAddressList);
while (as) {
// piCout << "[pAdapter]" << ci.name << PIString(as->IpAddress.String);
ci.address = PIString(as->IpAddress.String);
ci.netmask = PIString(as->IpMask.String);
if (ci.address == "0.0.0.0") {
as = as->Next;
continue;
}
il << ci;
as = as->Next;
}
/*if (ci.flags[PIEthernet::ifBroadcast])
ci.broadcast = getSockAddr(ret->ifa_broadaddr);
if (ci.flags[PIEthernet::ifPTP])
ci.ptp = getSockAddr(ret->ifa_dstaddr);*/
il << ci;
pAdapter = pAdapter->Next;
}
} else
@@ -1019,6 +1024,8 @@ PIStringList PIEthernet::allAddresses() {
PIStringList al;
piForeachC (PIEthernet::Interface & i, il)
al << i.address;
// piCout << "[PIEthernet::allAddresses]" << al;
if (!al.contains("127.0.0.1")) al << "127.0.0.1";
return al.removeStrings("0.0.0.0");
//#endif
}

View File

@@ -789,16 +789,18 @@ void PIPeer::reinit() {
void PIPeer::initNetwork() {
piCoutObj << "initNetwork ...";
// piCoutObj << "initNetwork ...";
eth_send.init();
destroyEths();
destroyMBcasts();
// piCoutObj << self_info.addresses.size();
self_info.addresses.clear();
PIStringList sl = PIEthernet::allAddresses();
initEths(sl);
// piCoutObj << sl << self_info.addresses.size();
sl.removeAll("127.0.0.1");
initMBcasts(sl);
piCoutObj << "initNetwork done";
// piCoutObj << "initNetwork done";
}

View File

@@ -20,13 +20,13 @@
#ifndef PIP_H
#define PIP_H
#include "pip/picoremodule.h"
#include "pip/picontainersmodule.h"
#include "pip/piconsolemodule.h"
#include "pip/pithreadmodule.h"
#include "pip/piiomodule.h"
#include "pip/pimathmodule.h"
#include "pip/pigeomodule.h"
#include "pip/pisystemmodule.h"
#include "picoremodule.h"
#include "picontainersmodule.h"
#include "piconsolemodule.h"
#include "pithreadmodule.h"
#include "piiomodule.h"
#include "pimathmodule.h"
#include "pisystemmodule.h"
#include "pigeomodule.h"
#endif // PIP_H