Commit 813c7189 authored by Pavel Vainerman's avatar Pavel Vainerman

(Modbus): исправил баг приводивший к deadlock. Заодно перевёл

MBExchange на использование rwmutex.
parent bae39000
#!/bin/sh
./uniset-start.sh -f "./uniset-admin --confile test.xml --`basename $0 .sh` $1 $2 $3 $4 $5"
./uniset2-start.sh -f "./uniset2-admin --confile test.xml --`basename $0 .sh` $1 $2 $3 $4"
exit $?
......@@ -2463,7 +2463,6 @@ void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
if( !force )
{
uniset_mutex_lock l(pollMutex,2000);
force = true;
poll();
force = false;
......@@ -2634,7 +2633,7 @@ void MBExchange::poll()
if( !mb )
{
{
uniset_mutex_lock l(pollMutex, 300);
uniset_rwmutex_wrlock l(pollMutex);
pollActivated = false;
mb = initMB(false);
if( !mb )
......@@ -2653,7 +2652,7 @@ void MBExchange::poll()
}
{
uniset_mutex_lock l(pollMutex);
uniset_rwmutex_wrlock l(pollMutex);
pollActivated = true;
ptTimeout.reset();
}
......@@ -2730,7 +2729,7 @@ void MBExchange::poll()
}
{
uniset_mutex_lock l(pollMutex);
uniset_rwmutex_wrlock l(pollMutex);
pollActivated = false;
}
......@@ -2754,7 +2753,6 @@ void MBExchange::poll()
if( allNotRespond && ptReopen.checkTime() )
{
uniset_mutex_lock l(pollMutex, 300);
dwarn << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true);
......@@ -2799,7 +2797,7 @@ void MBExchange::updateRespondSensors()
{
bool chanTimeout = false;
{
uniset_mutex_lock l(pollMutex);
uniset_rwmutex_rlock l(pollMutex);
chanTimeout = pollActivated && ptTimeout.checkTime();
}
......
......@@ -232,7 +232,7 @@ class MBExchange:
RTUDeviceMap rmap;
InitList initRegList; /*!< список регистров для инициализации */
UniSetTypes::uniset_mutex pollMutex;
UniSetTypes::uniset_rwmutex pollMutex;
virtual ModbusClient* initMB( bool reopen=false )= 0;
......
......@@ -138,7 +138,7 @@ void MBTCPMaster::sysCommand( const UniSetTypes::SystemMessage *sm )
void MBTCPMaster::poll_thread()
{
{
uniset_mutex_lock l(pollMutex,300);
uniset_rwmutex_wrlock l(pollMutex);
ptTimeout.reset();
}
......
......@@ -273,7 +273,7 @@ void MBTCPMultiMaster::sysCommand( const UniSetTypes::SystemMessage *sm )
void MBTCPMultiMaster::poll_thread()
{
{
uniset_mutex_lock l(pollMutex,300);
uniset_rwmutex_wrlock l(pollMutex);
ptTimeout.reset();
}
......
......@@ -172,7 +172,7 @@ void RTUExchange::poll()
if( !mb )
{
{
uniset_mutex_lock l(pollMutex, 300);
uniset_rwmutex_wrlock l(pollMutex);
pollActivated = false;
mb = initMB(false);
if( !mb )
......@@ -191,7 +191,7 @@ void RTUExchange::poll()
}
{
uniset_mutex_lock l(pollMutex,200);
uniset_rwmutex_wrlock l(pollMutex);
pollActivated = true;
ptTimeout.reset();
}
......@@ -305,7 +305,6 @@ void RTUExchange::poll()
if( allNotRespond && ptReopen.checkTime() )
{
uniset_mutex_lock l(pollMutex, 300);
dwarn << myname << ": REOPEN timeout..(" << ptReopen.getInterval() << ")" << endl;
mb = initMB(true);
......
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