Commit 9611abb0 authored by Pavel Vainerman's avatar Pavel Vainerman

(IOControl): minor optimization

parent 2537309a
...@@ -272,6 +272,7 @@ namespace uniset ...@@ -272,6 +272,7 @@ namespace uniset
uniset::uniset_rwmutex ioMutex; /*!< замок для блокирования совместного доступа к ioList */ uniset::uniset_rwmutex ioMutex; /*!< замок для блокирования совместного доступа к ioList */
bool isPingDBServer; // флаг связи с DBServer-ом bool isPingDBServer; // флаг связи с DBServer-ом
uniset::ObjectId dbserverID = { uniset::DefaultObjectId };
std::mutex loggingMutex; /*!< logging info mutex */ std::mutex loggingMutex; /*!< logging info mutex */
......
...@@ -43,6 +43,9 @@ IOController::IOController(const string& name, const string& section): ...@@ -43,6 +43,9 @@ IOController::IOController(const string& name, const string& section):
ioMutex(name + "_ioMutex"), ioMutex(name + "_ioMutex"),
isPingDBServer(true) isPingDBServer(true)
{ {
auto conf = uniset_conf();
if( conf )
dbserverID = conf->getDBServer();
} }
IOController::IOController(ObjectId id): IOController::IOController(ObjectId id):
...@@ -50,6 +53,9 @@ IOController::IOController(ObjectId id): ...@@ -50,6 +53,9 @@ IOController::IOController(ObjectId id):
ioMutex(string(uniset_conf()->oind->getMapName(id)) + "_ioMutex"), ioMutex(string(uniset_conf()->oind->getMapName(id)) + "_ioMutex"),
isPingDBServer(true) isPingDBServer(true)
{ {
auto conf = uniset_conf();
if( conf )
dbserverID = conf->getDBServer();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -412,16 +418,14 @@ void IOController::logging( uniset::SensorMessage& sm ) ...@@ -412,16 +418,14 @@ void IOController::logging( uniset::SensorMessage& sm )
try try
{ {
ObjectId dbID = uniset_conf()->getDBServer();
// значит на этом узле нет DBServer-а // значит на этом узле нет DBServer-а
if( dbID == uniset::DefaultObjectId ) if( dbserverID == uniset::DefaultObjectId )
{ {
isPingDBServer = false; isPingDBServer = false;
return; return;
} }
sm.consumer = dbID; sm.consumer = dbserverID;
TransportMessage tm(std::move(sm.transport_msg())); TransportMessage tm(std::move(sm.transport_msg()));
ui->send( sm.consumer, std::move(tm) ); ui->send( sm.consumer, std::move(tm) );
isPingDBServer = true; isPingDBServer = true;
...@@ -439,7 +443,7 @@ void IOController::logging( uniset::SensorMessage& sm ) ...@@ -439,7 +443,7 @@ void IOController::logging( uniset::SensorMessage& sm )
void IOController::dumpToDB() void IOController::dumpToDB()
{ {
// значит на этом узле нет DBServer-а // значит на этом узле нет DBServer-а
if( uniset_conf()->getDBServer() == uniset::DefaultObjectId ) if( dbserverID == uniset::DefaultObjectId )
return; return;
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment