Commit 9356415b authored by Pavel Vainerman's avatar Pavel Vainerman

make style..

parent 8df67095
......@@ -60,7 +60,7 @@ int main( int argc, char** argv )
std::list<ExtInfo> l;
for( auto&& it: lst )
for( auto && it : lst )
{
UniversalIO::IOType t = conf->getIOType( it.si.id );
......@@ -129,7 +129,7 @@ int main( int argc, char** argv )
cout << "\r" << " i = " << j << " " << flush;
for( const auto& it: l )
for( const auto& it : l )
{
try
{
......
......@@ -8,67 +8,67 @@
#include "DBServer.h"
//------------------------------------------------------------------------------------------
class DBServer_PostgreSQL:
public DBServer
public DBServer
{
public:
DBServer_PostgreSQL( UniSetTypes::ObjectId id, const std::string& prefix );
DBServer_PostgreSQL();
virtual ~DBServer_PostgreSQL();
public:
DBServer_PostgreSQL( UniSetTypes::ObjectId id, const std::string& prefix );
DBServer_PostgreSQL();
virtual ~DBServer_PostgreSQL();
static const Debug::type DBLogInfoLevel = Debug::LEVEL9;
static const Debug::type DBLogInfoLevel = Debug::LEVEL9;
/*! глобальная функция для инициализации объекта */
static std::shared_ptr<DBServer_PostgreSQL> init_dbserver( int argc, const char* const* argv, const std::string& prefix="pgsql" );
/*! глобальная функция для инициализации объекта */
static std::shared_ptr<DBServer_PostgreSQL> init_dbserver( int argc, const char* const* argv, const std::string& prefix = "pgsql" );
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
protected:
typedef std::map<int, std::string> DBTableMap;
protected:
typedef std::map<int, std::string> DBTableMap;
virtual void initDB( std::shared_ptr<PostgreSQLInterface>& db ){};
virtual void initDBTableMap(DBTableMap& tblMap){};
virtual void initDB( std::shared_ptr<PostgreSQLInterface>& db ) {};
virtual void initDBTableMap(DBTableMap& tblMap) {};
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override;
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) override;
virtual void sigterm( int signo ) override;
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override;
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) override;
virtual void sigterm( int signo ) override;
bool writeToBase( const string& query );
virtual void init_dbserver();
void createTables( std::shared_ptr<PostgreSQLInterface>& db );
bool writeToBase( const string& query );
virtual void init_dbserver();
void createTables( std::shared_ptr<PostgreSQLInterface>& db );
inline const char* tblName(int key)
{
return tblMap[key].c_str();
}
inline const char* tblName(int key)
{
return tblMap[key].c_str();
}
enum Timers
{
PingTimer, /*!< таймер на переодическую проверку соединения с сервером БД */
ReconnectTimer, /*!< таймер на повторную попытку соединения с сервером БД (или восстановления связи) */
lastNumberOfTimer
};
enum Timers
{
PingTimer, /*!< таймер на переодическую проверку соединения с сервером БД */
ReconnectTimer, /*!< таймер на повторную попытку соединения с сервером БД (или восстановления связи) */
lastNumberOfTimer
};
std::shared_ptr<PostgreSQLInterface> db;
int PingTime;
int ReconnectTime;
bool connect_ok; /*! признак наличия соеднинения с сервером БД */
std::shared_ptr<PostgreSQLInterface> db;
int PingTime;
int ReconnectTime;
bool connect_ok; /*! признак наличия соеднинения с сервером БД */
bool activate;
bool activate;
typedef std::queue<std::string> QueryBuffer;
typedef std::queue<std::string> QueryBuffer;
QueryBuffer qbuf;
unsigned int qbufSize; // размер буфера сообщений.
bool lastRemove;
QueryBuffer qbuf;
unsigned int qbufSize; // размер буфера сообщений.
bool lastRemove;
void flushBuffer();
UniSetTypes::uniset_mutex mqbuf;
void flushBuffer();
UniSetTypes::uniset_mutex mqbuf;
private:
DBTableMap tblMap;
private:
DBTableMap tblMap;
};
//------------------------------------------------------------------------------------------
......
......@@ -10,189 +10,189 @@ using namespace pqxx;
// --------------------------------------------------------------------------
PostgreSQLInterface::PostgreSQLInterface():
lastQ(""),
lastE(""),
last_inserted_id(0)
lastQ(""),
lastE(""),
last_inserted_id(0)
{
//db = make_shared<pqxx::connection>();
//db = make_shared<pqxx::connection>();
}
PostgreSQLInterface::~PostgreSQLInterface()
{
close();
close();
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::ping()
{
return db && db->is_open();
return db && db->is_open();
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::connect( const string& host, const string& user, const string& pswd, const string& dbname)
{
if( db )
return true;
if( db )
return true;
std::string conninfo ="dbname="+dbname+" host="+host+" user="+user+" password="+pswd;
std::string conninfo = "dbname=" + dbname + " host=" + host + " user=" + user + " password=" + pswd;
try
{
db = make_shared<pqxx::connection>(conninfo);
return db->is_open();
try
{
db = make_shared<pqxx::connection>(conninfo);
return db->is_open();
}
catch( const std::exception &e )
{
cerr << e.what() << std::endl;
}
}
catch( const std::exception& e )
{
cerr << e.what() << std::endl;
}
return false;
return false;
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::close()
{
if( db )
{
db->disconnect();
db.reset();
}
if( db )
{
db->disconnect();
db.reset();
}
return true;
return true;
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::insert( const string& q )
{
if( !db )
return false;
if( !db )
return false;
try
{
work w( *(db.get()) );
w.exec(q);
w.commit();
return true;
}
catch( const std::exception &e )
{
//cerr << e.what() << std::endl;
lastE = string(e.what());
}
try
{
work w( *(db.get()) );
w.exec(q);
w.commit();
return true;
}
catch( const std::exception& e )
{
//cerr << e.what() << std::endl;
lastE = string(e.what());
}
return false;
return false;
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::insertAndSaveRowid( const string& q )
{
if( !db )
return false;
if( !db )
return false;
std::string qplus=q+" RETURNING id";
std::string qplus = q + " RETURNING id";
try
{
work w( *(db.get()) );
pqxx::result res = w.exec(qplus);
w.commit();
save_inserted_id(res);
return true;
}
catch( const std::exception &e )
{
//cerr << e.what() << std::endl;
lastE = string(e.what());
}
try
{
work w( *(db.get()) );
pqxx::result res = w.exec(qplus);
w.commit();
save_inserted_id(res);
return true;
}
catch( const std::exception& e )
{
//cerr << e.what() << std::endl;
lastE = string(e.what());
}
return false;
return false;
}
// -----------------------------------------------------------------------------------------
PostgreSQLResult PostgreSQLInterface::query( const string& q )
{
if( !db )
return PostgreSQLResult();
if( !db )
return PostgreSQLResult();
try
{
nontransaction n(*(db.get()));
try
{
nontransaction n(*(db.get()));
/* Execute SQL query */
result res( n.exec(q) );
return PostgreSQLResult(res);
}
catch( const std::exception &e )
{
lastE = string(e.what());
}
/* Execute SQL query */
result res( n.exec(q) );
return PostgreSQLResult(res);
}
catch( const std::exception& e )
{
lastE = string(e.what());
}
return PostgreSQLResult();
return PostgreSQLResult();
}
// -----------------------------------------------------------------------------------------
string PostgreSQLInterface::error()
{
return lastE;
return lastE;
}
// -----------------------------------------------------------------------------------------
const string PostgreSQLInterface::lastQuery()
{
return lastQ;
return lastQ;
}
// -----------------------------------------------------------------------------------------
double PostgreSQLInterface::insert_id()
{
return last_inserted_id;
return last_inserted_id;
}
// -----------------------------------------------------------------------------------------
void PostgreSQLInterface::save_inserted_id( const pqxx::result& res )
{
if( res.size() > 0 && res[0].size() > 0 )
last_inserted_id = res[0][0].as<int>();
if( res.size() > 0 && res[0].size() > 0 )
last_inserted_id = res[0][0].as<int>();
}
// -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::isConnection()
{
return (db && db->is_open());
return (db && db->is_open());
}
// -----------------------------------------------------------------------------------------
int num_cols( PostgreSQLResult::iterator& it )
{
return it->size();
return it->size();
}
// -----------------------------------------------------------------------------------------
int as_int( PostgreSQLResult::iterator& it, int col )
{
// if( col<0 || col >it->size() )
// return 0;
return uni_atoi( (*it)[col] );
// if( col<0 || col >it->size() )
// return 0;
return uni_atoi( (*it)[col] );
}
// -----------------------------------------------------------------------------------------
double as_double( PostgreSQLResult::iterator& it, int col )
{
return atof( ((*it)[col]).c_str() );
return atof( ((*it)[col]).c_str() );
}
// -----------------------------------------------------------------------------------------
string as_string( PostgreSQLResult::iterator& it, int col )
{
return ((*it)[col]);
return ((*it)[col]);
}
// -----------------------------------------------------------------------------------------
int as_int( PostgreSQLResult::COL::iterator& it )
{
return uni_atoi( (*it) );
return uni_atoi( (*it) );
}
// -----------------------------------------------------------------------------------------
double as_double( PostgreSQLResult::COL::iterator& it )
{
return atof( (*it).c_str() );
return atof( (*it).c_str() );
}
// -----------------------------------------------------------------------------------------
std::string as_string( PostgreSQLResult::COL::iterator& it )
{
return (*it);
return (*it);
}
// -----------------------------------------------------------------------------------------
#if 0
PostgreSQLResult::COL get_col( PostgreSQLResult::ROW::iterator& it )
{
return (*it);
return (*it);
}
#endif
// -----------------------------------------------------------------------------------------
......@@ -203,12 +203,14 @@ PostgreSQLResult::~PostgreSQLResult()
// -----------------------------------------------------------------------------------------
PostgreSQLResult::PostgreSQLResult( const pqxx::result& res )
{
for (result::const_iterator c = res.begin(); c != res.end(); ++c)
{
COL col;
for( int i=0; i<c.size(); i++ )
col.push_back( c[i].as<string>() );
row.push_back(col);
}
for (result::const_iterator c = res.begin(); c != res.end(); ++c)
{
COL col;
for( int i = 0; i < c.size(); i++ )
col.push_back( c[i].as<string>() );
row.push_back(col);
}
}
// -----------------------------------------------------------------------------------------
......@@ -13,59 +13,74 @@ class PostgreSQLResult;
// ----------------------------------------------------------------------------
class PostgreSQLInterface
{
public:
public:
PostgreSQLInterface();
~PostgreSQLInterface();
PostgreSQLInterface();
~PostgreSQLInterface();
bool connect( const std::string& host, const std::string& user, const std::string& pswd, const std::string& dbname );
bool close();
bool isConnection();
bool ping(); // проверка доступности БД
bool connect( const std::string& host, const std::string& user, const std::string& pswd, const std::string& dbname );
bool close();
bool isConnection();
bool ping(); // проверка доступности БД
PostgreSQLResult query( const std::string& q );
const std::string lastQuery();
PostgreSQLResult query( const std::string& q );
const std::string lastQuery();
bool insert( const std::string& q );
bool insertAndSaveRowid( const std::string& q );
double insert_id();
void save_inserted_id( const pqxx::result& res );
bool insert( const std::string& q );
bool insertAndSaveRowid( const std::string& q );
double insert_id();
void save_inserted_id( const pqxx::result& res );
std::string error();
std::string error();
protected:
protected:
private:
private:
std::shared_ptr<pqxx::connection> db;
std::string lastQ;
std::string lastE;
double last_inserted_id;
std::shared_ptr<pqxx::connection> db;
std::string lastQ;
std::string lastE;
double last_inserted_id;
};
// ----------------------------------------------------------------------------------
class PostgreSQLResult
{
public:
PostgreSQLResult(){}
PostgreSQLResult( const pqxx::result& res );
~PostgreSQLResult();
public:
PostgreSQLResult() {}
PostgreSQLResult( const pqxx::result& res );
~PostgreSQLResult();
typedef std::vector<std::string> COL;
typedef std::list<COL> ROW;
typedef std::vector<std::string> COL;
typedef std::list<COL> ROW;
typedef ROW::iterator iterator;
typedef ROW::iterator iterator;
inline iterator begin(){ return row.begin(); }
inline iterator end(){ return row.end(); }
inline iterator begin()
{
return row.begin();
}
inline iterator end()
{
return row.end();
}
inline operator bool(){ return !row.empty(); }
inline operator bool()
{
return !row.empty();
}
inline int size(){ return row.size(); }
inline bool empty(){ return row.empty(); }
inline int size()
{
return row.size();
}
inline bool empty()
{
return row.empty();
}
protected:
protected:
ROW row;
ROW row;
};
// ----------------------------------------------------------------------------
int num_cols( PostgreSQLResult::iterator& );
......
......@@ -8,33 +8,33 @@ using namespace std;
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
try
{
if( argc > 1 && !strcmp(argv[1],"--help") )
{
DBServer_PostgreSQL::help_print(argc,argv);
return 0;
}
try
{
if( argc > 1 && !strcmp(argv[1], "--help") )
{
DBServer_PostgreSQL::help_print(argc, argv);
return 0;
}
auto conf = uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc, argv, "configure.xml");
auto dbs = DBServer_PostgreSQL::init_dbserver(argc,argv);
auto act = UniSetActivator::Instance();
act->add(dbs);
act->run(false);
}
catch( const Exception& ex )
{
cerr << "(DBServer_PosgreSQL::main): " << ex << endl;
}
catch( std::exception& ex )
{
cerr << "(DBServer_PosgreSQL::main): " << ex.what() << endl;
}
catch(...)
{
cerr << "(DBServer_PosgreSQL::main): catch ..." << endl;
}
auto dbs = DBServer_PostgreSQL::init_dbserver(argc, argv);
auto act = UniSetActivator::Instance();
act->add(dbs);
act->run(false);
}
catch( const Exception& ex )
{
cerr << "(DBServer_PosgreSQL::main): " << ex << endl;
}
catch( std::exception& ex )
{
cerr << "(DBServer_PosgreSQL::main): " << ex.what() << endl;
}
catch(...)
{
cerr << "(DBServer_PosgreSQL::main): catch ..." << endl;
}
return 0;
return 0;
}
......@@ -8,54 +8,58 @@ using namespace std;
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
std::string dbname("test-db");
if( argc > 1 )
dbname = string(argv[1]);
try
{
PostgreSQLInterface db;
if( !db.connect("localhost","dbadmin","dbadmin",dbname) )
{
cerr << "db connect error: " << db.error() << endl;
return 1;
}
stringstream q;
q << "SELECT * from main_history";
PostgreSQLResult r = db.query(q.str());
if( !r )
{
cerr << "db connect error: " << db.error() << endl;
return 1;
}
for( PostgreSQLResult::iterator it=r.begin(); it!=r.end(); it++ )
{
cout << "ROW: ";
PostgreSQLResult::COL col(*it);
for( PostgreSQLResult::COL::iterator cit = it->begin(); cit!=it->end(); cit++ )
cout << as_string(cit) << "(" << as_double(cit) << ") | ";
cout << endl;
}
db.close();
}
catch( const Exception& ex )
{
cerr << "(test): " << ex << endl;
}
catch( std::exception& ex )
{
cerr << "(test): " << ex.what() << endl;
}
catch(...)
{
cerr << "(test): catch ..." << endl;
}
return 0;
std::string dbname("test-db");
if( argc > 1 )
dbname = string(argv[1]);
try
{
PostgreSQLInterface db;
if( !db.connect("localhost", "dbadmin", "dbadmin", dbname) )
{
cerr << "db connect error: " << db.error() << endl;
return 1;
}
stringstream q;
q << "SELECT * from main_history";
PostgreSQLResult r = db.query(q.str());
if( !r )
{
cerr << "db connect error: " << db.error() << endl;
return 1;
}
for( PostgreSQLResult::iterator it = r.begin(); it != r.end(); it++ )
{
cout << "ROW: ";
PostgreSQLResult::COL col(*it);
for( PostgreSQLResult::COL::iterator cit = it->begin(); cit != it->end(); cit++ )
cout << as_string(cit) << "(" << as_double(cit) << ") | ";
cout << endl;
}
db.close();
}
catch( const Exception& ex )
{
cerr << "(test): " << ex << endl;
}
catch( std::exception& ex )
{
cerr << "(test): " << ex.what() << endl;
}
catch(...)
{
cerr << "(test): catch ..." << endl;
}
return 0;
}
......@@ -26,7 +26,8 @@ PassiveLProcessor::PassiveLProcessor( UniSetTypes::ObjectId objId,
UniXML::iterator it(confnode);
confnode = conf->getNode(myname);
string lfile = conf->getArgParam("--" + prefix + "-schema",it.getProp("schema"));
string lfile = conf->getArgParam("--" + prefix + "-schema", it.getProp("schema"));
if( lfile.empty() )
{
ostringstream err;
......
......@@ -30,7 +30,7 @@ class PassiveLProcessor:
static void help_print( int argc, const char* const* argv );
static std::shared_ptr<PassiveLProcessor> init_plproc( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, const std::shared_ptr<SharedMemory> ic = nullptr,
UniSetTypes::ObjectId shmID, const std::shared_ptr<SharedMemory> ic = nullptr,
const std::string& prefix = "plproc" );
protected:
......
......@@ -60,7 +60,7 @@ int main(int argc, const char** argv)
return 1;
}
auto plp = PassiveLProcessor::init_plproc(argc,argv,shmID);
auto plp = PassiveLProcessor::init_plproc(argc, argv, shmID);
auto act = UniSetActivator::Instance();
act->add(plp);
......
......@@ -1285,7 +1285,7 @@ ModbusRTU::mbErrCode MBSlave::real_write_it( IOMap::iterator& it, ModbusRTU::Mod
if( p->bitreg )
return real_bitreg_write_it(p->bitreg, dat[i++]);
return real_write_prop(p,dat,i,count);
return real_write_prop(p, dat, i, count);
}
// -------------------------------------------------------------------------
ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProperty>& bp, const ModbusRTU::ModbusData val )
......@@ -1302,13 +1302,13 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
if( p->si.id == DefaultObjectId )
continue;
ModbusRTU::ModbusData dat[]={d[i]};
ModbusRTU::ModbusData dat[] = {d[i]};
dinfo << myname << "(real_bitreg_write_it): set " << ModbusRTU::dat2str(bp->mbreg) << "(" << (int)bp->mbreg << ")"
<< " bit[" << i << "]=" << (int)dat[0] << " sid=" << p->si.id << endl;
<< " bit[" << i << "]=" << (int)dat[0] << " sid=" << p->si.id << endl;
int k=0;
real_write_prop(p,dat,k,1);
int k = 0;
real_write_prop(p, dat, k, 1);
}
return ModbusRTU::erNoError;
......@@ -1317,6 +1317,7 @@ ModbusRTU::mbErrCode MBSlave::real_bitreg_write_it( std::shared_ptr<BitRegProper
ModbusRTU::mbErrCode MBSlave::real_write_prop( IOProperty* p, ModbusRTU::ModbusData* dat, int& i, int count )
{
ModbusRTU::ModbusData mbval = dat[i++];
try
{
if( p->amode == MBSlave::amRO )
......
......@@ -979,14 +979,14 @@ TEST_CASE("Write(0x06,0x10): nbit", "[modbus][mbslave][mbtcpslave][writenbit]")
SECTION("Test: write06")
{
ModbusRTU::WriteSingleOutputRetMessage ret = mb->write06(slaveaddr, tREG,3);
ModbusRTU::WriteSingleOutputRetMessage ret = mb->write06(slaveaddr, tREG, 3);
REQUIRE( ret.start == tREG );
REQUIRE( ret.data == 3 );
REQUIRE( ui->getValue(2020) == 1 );
REQUIRE( ui->getValue(2021) == 1 );
REQUIRE( ui->getValue(2022) == 0 );
ret = mb->write06(slaveaddr, tREG,0);
ret = mb->write06(slaveaddr, tREG, 0);
REQUIRE( ret.start == tREG );
REQUIRE( ret.data == 0 );
REQUIRE( ui->getValue(2020) == 0 );
......
......@@ -243,7 +243,7 @@ bool SharedMemory::activateObject()
res = IONotifyController_LT::activateObject();
// инициализируем указатели
for( auto&& it : hlist )
for( auto && it : hlist )
{
it.a_it = myioEnd();
it.d_it = myioEnd();
......@@ -253,7 +253,7 @@ bool SharedMemory::activateObject()
for( auto& it : hist )
{
for( auto&& hit : it.hlst )
for( auto && hit : it.hlst )
hit.ioit = myioEnd();
}
......
......@@ -37,13 +37,13 @@ TEST_CASE("[SM]: get/set", "[sm][getset]")
{
InitTest();
ui->setValue(500,30);
ui->setValue(500, 30);
CHECK( ui->getValue(500) == 30 );
ui->setValue(500,-30);
ui->setValue(500, -30);
CHECK( ui->getValue(500) == -30 );
ui->setValue(500,0);
ui->setValue(500, 0);
CHECK( ui->getValue(500) == 0 );
}
// -----------------------------------------------------------------------------
......@@ -51,19 +51,20 @@ TEST_CASE("[SM]: threshold", "[sm][threshold]")
{
InitTest();
ui->setValue(503,30);
ui->setValue(503, 30);
CHECK( ui->getValue(504) == 0 );
ui->setValue(503,400);
ui->setValue(503, 400);
CHECK( ui->getValue(504) == 1 );
ui->setValue(503,25);
ui->setValue(503, 25);
CHECK( ui->getValue(504) == 0 );
}
// -----------------------------------------------------------------------------
TEST_CASE("[SM]: pulsar", "[sm][pulsar]")
{
InitTest();
while( ui->getValue(505) )
msleep(50);
......@@ -81,13 +82,13 @@ TEST_CASE("[SM]: heartbeat", "[sm][heartbeat]")
InitTest();
CHECK_FALSE( ui->getValue(507) );
ui->setValue(506,2);
ui->setValue(506, 2);
msleep(500);
CHECK( ui->getValue(507) );
msleep(2000);
CHECK_FALSE( ui->getValue(507) );
ui->setValue(506,4);
ui->setValue(506, 4);
msleep(2000);
CHECK( ui->getValue(507) );
}
......
......@@ -35,7 +35,7 @@ class TCPCheck
* \note Вызывается через system()! Это может быть опасно с точки зрения безопасности..
* \todo Возможно стоит написать свою реализацию ping
*/
bool ping( const std::string& _ip, timeout_t tout = 1000, timeout_t sleep_msec = 200, const std::string& ping_argc="-c 1 -w 0.1 -q -n" );
bool ping( const std::string& _ip, timeout_t tout = 1000, timeout_t sleep_msec = 200, const std::string& ping_argc = "-c 1 -w 0.1 -q -n" );
protected:
......@@ -52,7 +52,7 @@ class TCPCheck
int port = {0};
int tout_msec;
std::string ping_args={"-c 1 -w 0.1 -q -n"};
std::string ping_args = {"-c 1 -w 0.1 -q -n"};
};
// -----------------------------------------------------------------------------
#endif // _TCPCheck_H_
......
......@@ -54,6 +54,7 @@ bool TCPCheck::check( const std::string& _ip, int _port, timeout_t tout, timeout
void TCPCheck::check_thread()
{
setResult(false);
try
{
ost::Thread::setException(ost::Thread::throwException);
......@@ -98,6 +99,6 @@ void TCPCheck::ping_thread()
int ret = system(cmd.str().c_str());
int res = WEXITSTATUS(ret);
setResult((res==0));
setResult((res == 0));
}
// -----------------------------------------------------------------------------
......@@ -33,7 +33,7 @@ class TSRunner
TSRunner()
{
cancel = false;
res = std::async(std::launch::async,run_test_server);
res = std::async(std::launch::async, run_test_server);
}
~TSRunner()
......
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