git-svn-id: svn://db.shs.com.ru/pip@225 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -77,6 +77,9 @@ bool PIBinaryLog::openDevice() {
|
|||||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
|
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (path().isEmpty() && mode_ == WriteOnly) {
|
||||||
|
setPath(getLogfilePath());
|
||||||
|
}
|
||||||
if (!file.open(path(), mode_)) {
|
if (!file.open(path(), mode_)) {
|
||||||
piCoutObj << "Error: Can't open file" << path();
|
piCoutObj << "Error: Can't open file" << path();
|
||||||
return false;
|
return false;
|
||||||
@@ -177,8 +180,7 @@ bool PIBinaryLog::threadedRead(uchar *readed, int size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIBinaryLog::createNewFile() {
|
PIString PIBinaryLog::getLogfilePath() const {
|
||||||
if (!file.close()) return PIString();
|
|
||||||
PIDir dir(logDir());
|
PIDir dir(logDir());
|
||||||
dir.setDir(dir.absolutePath());
|
dir.setDir(dir.absolutePath());
|
||||||
if (!dir.isExists()) {
|
if (!dir.isExists()) {
|
||||||
@@ -192,6 +194,12 @@ PIString PIBinaryLog::createNewFile() {
|
|||||||
cnpath = npath + "_" + PIString::fromNumber(i) + ".binlog";
|
cnpath = npath + "_" + PIString::fromNumber(i) + ".binlog";
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
return cnpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
PIString PIBinaryLog::createNewFile() {
|
||||||
|
if (!file.close()) return PIString();
|
||||||
|
PIString cnpath = getLogfilePath();
|
||||||
if (open(cnpath, PIIODevice::WriteOnly)) {
|
if (open(cnpath, PIIODevice::WriteOnly)) {
|
||||||
newFile(file.path());
|
newFile(file.path());
|
||||||
return file.path();
|
return file.path();
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ private:
|
|||||||
BinLogRecord readRecord();
|
BinLogRecord readRecord();
|
||||||
static void parseLog(PIFile *f, BinLogInfo *info, PIVector<BinLogIndex> * index);
|
static void parseLog(PIFile *f, BinLogInfo *info, PIVector<BinLogIndex> * index);
|
||||||
void moveIndex(int i);
|
void moveIndex(int i);
|
||||||
|
PIString getLogfilePath() const;
|
||||||
|
|
||||||
PIVector<BinLogIndex> index;
|
PIVector<BinLogIndex> index;
|
||||||
PIMap<llong, int> index_pos;
|
PIMap<llong, int> index_pos;
|
||||||
|
|||||||
@@ -799,13 +799,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
while (pAdapter) {
|
while (pAdapter) {
|
||||||
ci.name = PIString(pAdapter->AdapterName);
|
ci.name = PIString(pAdapter->AdapterName);
|
||||||
ci.index = pAdapter->Index;
|
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.mac = macFromBytes(PIByteArray(pAdapter->Address, pAdapter->AddressLength));
|
||||||
ci.netmask = PIString(pAdapter->IpAddressList.IpMask.String);
|
|
||||||
ci.flags = PIEthernet::ifActive | PIEthernet::ifRunning;
|
ci.flags = PIEthernet::ifActive | PIEthernet::ifRunning;
|
||||||
//if (ret->ifa_flags & IFF_BROADCAST) ci.flags |= PIEthernet::ifBroadcast;
|
//if (ret->ifa_flags & IFF_BROADCAST) ci.flags |= PIEthernet::ifBroadcast;
|
||||||
//if (ret->ifa_flags & IFF_MULTICAST) ci.flags |= PIEthernet::ifMulticast;
|
//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;
|
if (pAdapter->Type == MIB_IF_TYPE_LOOPBACK) ci.flags |= PIEthernet::ifLoopback;
|
||||||
ci.broadcast.clear();
|
ci.broadcast.clear();
|
||||||
ci.ptp.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])
|
/*if (ci.flags[PIEthernet::ifBroadcast])
|
||||||
ci.broadcast = getSockAddr(ret->ifa_broadaddr);
|
ci.broadcast = getSockAddr(ret->ifa_broadaddr);
|
||||||
if (ci.flags[PIEthernet::ifPTP])
|
if (ci.flags[PIEthernet::ifPTP])
|
||||||
ci.ptp = getSockAddr(ret->ifa_dstaddr);*/
|
ci.ptp = getSockAddr(ret->ifa_dstaddr);*/
|
||||||
il << ci;
|
|
||||||
pAdapter = pAdapter->Next;
|
pAdapter = pAdapter->Next;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -1019,6 +1024,8 @@ PIStringList PIEthernet::allAddresses() {
|
|||||||
PIStringList al;
|
PIStringList al;
|
||||||
piForeachC (PIEthernet::Interface & i, il)
|
piForeachC (PIEthernet::Interface & i, il)
|
||||||
al << i.address;
|
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");
|
return al.removeStrings("0.0.0.0");
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -789,16 +789,18 @@ void PIPeer::reinit() {
|
|||||||
|
|
||||||
|
|
||||||
void PIPeer::initNetwork() {
|
void PIPeer::initNetwork() {
|
||||||
piCoutObj << "initNetwork ...";
|
// piCoutObj << "initNetwork ...";
|
||||||
eth_send.init();
|
eth_send.init();
|
||||||
destroyEths();
|
destroyEths();
|
||||||
destroyMBcasts();
|
destroyMBcasts();
|
||||||
|
// piCoutObj << self_info.addresses.size();
|
||||||
self_info.addresses.clear();
|
self_info.addresses.clear();
|
||||||
PIStringList sl = PIEthernet::allAddresses();
|
PIStringList sl = PIEthernet::allAddresses();
|
||||||
initEths(sl);
|
initEths(sl);
|
||||||
|
// piCoutObj << sl << self_info.addresses.size();
|
||||||
sl.removeAll("127.0.0.1");
|
sl.removeAll("127.0.0.1");
|
||||||
initMBcasts(sl);
|
initMBcasts(sl);
|
||||||
piCoutObj << "initNetwork done";
|
// piCoutObj << "initNetwork done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
src/pip.h
16
src/pip.h
@@ -20,13 +20,13 @@
|
|||||||
#ifndef PIP_H
|
#ifndef PIP_H
|
||||||
#define PIP_H
|
#define PIP_H
|
||||||
|
|
||||||
#include "pip/picoremodule.h"
|
#include "picoremodule.h"
|
||||||
#include "pip/picontainersmodule.h"
|
#include "picontainersmodule.h"
|
||||||
#include "pip/piconsolemodule.h"
|
#include "piconsolemodule.h"
|
||||||
#include "pip/pithreadmodule.h"
|
#include "pithreadmodule.h"
|
||||||
#include "pip/piiomodule.h"
|
#include "piiomodule.h"
|
||||||
#include "pip/pimathmodule.h"
|
#include "pimathmodule.h"
|
||||||
#include "pip/pigeomodule.h"
|
#include "pisystemmodule.h"
|
||||||
#include "pip/pisystemmodule.h"
|
#include "pigeomodule.h"
|
||||||
|
|
||||||
#endif // PIP_H
|
#endif // PIP_H
|
||||||
|
|||||||
Reference in New Issue
Block a user