git-svn-id: svn://db.shs.com.ru/pip@819 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "piintrospection_server.h"
|
||||
#include "piintrospection_server_p.h"
|
||||
#include "piprocess.h"
|
||||
#include "pichunkstream.h"
|
||||
|
||||
|
||||
@@ -31,15 +32,32 @@ PRIVATE_DEFINITION_END(PIIntrospectionServer)
|
||||
|
||||
PIIntrospectionServer::PIIntrospectionServer(): PIPeer(genName()) {
|
||||
PRIVATE->process_info = PIIntrospection::getInfo();
|
||||
sysmon = 0;
|
||||
}
|
||||
|
||||
|
||||
PIIntrospectionServer::~PIIntrospectionServer() {
|
||||
PIPeer::stop();
|
||||
if (sysmon)
|
||||
if (sysmon->property("__iserver__").toBool())
|
||||
delete sysmon;
|
||||
sysmon = 0;
|
||||
}
|
||||
|
||||
|
||||
void PIIntrospectionServer::start() {
|
||||
if (!sysmon) {
|
||||
sysmon = PISystemMonitor::Pool::instance()->getByPID(PIProcess::currentPID());
|
||||
if (sysmon) {
|
||||
piCoutObj << "using existing sysmon";
|
||||
CONNECTU(sysmon, deleted, this, sysmonDeleted);
|
||||
} else {
|
||||
piCoutObj << "create own sysmon";
|
||||
sysmon = new PISystemMonitor();
|
||||
sysmon->setProperty("__iserver__", true);
|
||||
sysmon->startOnSelf();
|
||||
}
|
||||
}
|
||||
PIPeer::start();
|
||||
}
|
||||
|
||||
@@ -60,6 +78,11 @@ void PIIntrospectionServer::dataReceived(const PIString & from, const PIByteArra
|
||||
PIChunkStream cs;
|
||||
if (ri.types[PIIntrospection::itInfo])
|
||||
cs.add(PIIntrospection::itInfo, PIIntrospection::packInfo());
|
||||
if (ri.types[PIIntrospection::itProcStat]) {
|
||||
sysmon_mutex.lock();
|
||||
cs.add(PIIntrospection::itProcStat, PIIntrospection::packProcStat(sysmon));
|
||||
sysmon_mutex.unlock();
|
||||
}
|
||||
if (ri.types[PIIntrospection::itContainers])
|
||||
cs.add(PIIntrospection::itContainers, PIIntrospection::packContainers());
|
||||
if (ri.types[PIIntrospection::itObjects])
|
||||
@@ -72,5 +95,10 @@ void PIIntrospectionServer::dataReceived(const PIString & from, const PIByteArra
|
||||
send(from, ba);
|
||||
}
|
||||
|
||||
#endif // PIP_INTROSPECTION
|
||||
|
||||
void PIIntrospectionServer::sysmonDeleted() {
|
||||
PIMutexLocker _ml(sysmon_mutex);
|
||||
sysmon = 0;
|
||||
}
|
||||
|
||||
#endif // PIP_INTROSPECTION
|
||||
|
||||
Reference in New Issue
Block a user