You need to sign in or sign up before continuing.
Commit 365e4539 authored by Pavel Vainerman's avatar Pavel Vainerman

add ConsumerMaxAttempts property got IONotifyController

parent 2bb127f4
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.97 Version: 0.97
Release: eter11 Release: eter12
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -178,6 +178,9 @@ rm -f %buildroot%_libdir/*.la ...@@ -178,6 +178,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Fri Sep 25 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter11
- return old mutex
* Wed Sep 23 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter10 * Wed Sep 23 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter10
- new build - new build
......
...@@ -82,11 +82,12 @@ class IONotifyController: ...@@ -82,11 +82,12 @@ class IONotifyController:
public UniSetTypes::ConsumerInfo public UniSetTypes::ConsumerInfo
{ {
ConsumerInfoExt( const UniSetTypes::ConsumerInfo& ci, ConsumerInfoExt( const UniSetTypes::ConsumerInfo& ci,
UniSetObject_i_ptr ref=0): UniSetObject_i_ptr ref=0, int maxAttemtps = 10 ):
UniSetTypes::ConsumerInfo(ci), UniSetTypes::ConsumerInfo(ci),
ref(ref){} ref(ref),attempt(maxAttemtps){}
UniSetObject_i_var ref; UniSetObject_i_var ref;
int attempt;
}; };
typedef std::list<ConsumerInfoExt> ConsumerList; typedef std::list<ConsumerInfoExt> ConsumerList;
...@@ -250,6 +251,8 @@ class IONotifyController: ...@@ -250,6 +251,8 @@ class IONotifyController:
UniSetTypes::uniset_mutex askAOMutex; UniSetTypes::uniset_mutex askAOMutex;
/*! c */ /*! c */
UniSetTypes::uniset_mutex askDOMutex; UniSetTypes::uniset_mutex askDOMutex;
int maxAttemtps; /*! timeout for consumer */
}; };
#endif #endif
...@@ -44,16 +44,19 @@ IONotifyController::IONotifyController(): ...@@ -44,16 +44,19 @@ IONotifyController::IONotifyController():
restorer(NULL), restorer(NULL),
askDMutex("askDMutex"), askDMutex("askDMutex"),
askAMutex("askAMutex"), askAMutex("askAMutex"),
trshMutex("trshMutex") trshMutex("trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
{ {
} }
IONotifyController::IONotifyController(const string name, const string section, NCRestorer* d): IONotifyController::IONotifyController(const string name, const string section, NCRestorer* d ):
IOController(name, section), IOController(name, section),
restorer(d), restorer(d),
askDMutex(name+"askDMutex"), askDMutex(name+"askDMutex"),
askAMutex(name+"askAMutex"), askAMutex(name+"askAMutex"),
trshMutex(name+"trshMutex") trshMutex(name+"trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
{ {
// //
addAFilter( sigc::mem_fun(this,&IONotifyController::myAFilter) ); addAFilter( sigc::mem_fun(this,&IONotifyController::myAFilter) );
...@@ -66,7 +69,8 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ): ...@@ -66,7 +69,8 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ):
restorer(d), restorer(d),
askDMutex(string(conf->oind->getMapName(id))+"_askDMutex"), askDMutex(string(conf->oind->getMapName(id))+"_askDMutex"),
askAMutex(string(conf->oind->getMapName(id))+"_askAMutex"), askAMutex(string(conf->oind->getMapName(id))+"_askAMutex"),
trshMutex(string(conf->oind->getMapName(id))+"_trshMutex") trshMutex(string(conf->oind->getMapName(id))+"_trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
{ {
// //
addAFilter( sigc::mem_fun(this,&IONotifyController::myAFilter) ); addAFilter( sigc::mem_fun(this,&IONotifyController::myAFilter) );
...@@ -74,7 +78,6 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ): ...@@ -74,7 +78,6 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ):
setDependsSlot( sigc::mem_fun(this,&IONotifyController::onChangeUndefined) ); setDependsSlot( sigc::mem_fun(this,&IONotifyController::onChangeUndefined) );
} }
IONotifyController::~IONotifyController() IONotifyController::~IONotifyController()
{ {
} }
...@@ -112,7 +115,7 @@ bool IONotifyController::addConsumer(ConsumerList& lst, const ConsumerInfo& ci ) ...@@ -112,7 +115,7 @@ bool IONotifyController::addConsumer(ConsumerList& lst, const ConsumerInfo& ci )
return false; return false;
} }
ConsumerInfoExt cinf(ci); ConsumerInfoExt cinf(ci,0,maxAttemtps);
// //
try try
{ {
...@@ -567,7 +570,7 @@ void IONotifyController::localSaveValue( IOController::AIOStateList::iterator& l ...@@ -567,7 +570,7 @@ void IONotifyController::localSaveValue( IOController::AIOStateList::iterator& l
AskMap::iterator it = askAIOList.find( key(si.id,si.node) ); AskMap::iterator it = askAIOList.find( key(si.id,si.node) );
if( it!=askAIOList.end() ) if( it!=askAIOList.end() )
{ // lock { // lock
uniset_mutex_lock lock(askAMutex, 1000); uniset_mutex_lock lock(askAMutex, 1000);
send(it->second, sm); send(it->second, sm);
} }
...@@ -599,9 +602,10 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm) ...@@ -599,9 +602,10 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
li->ref = UniSetObject_i::_narrow(op); li->ref = UniSetObject_i::_narrow(op);
} }
sm.consumer = li->id; sm.consumer = li->id;
li->ref->push( sm.transport_msg() ); li->ref->push( sm.transport_msg() );
break; li->attempt = maxAttemtps; // reinit attempts
break;
} }
catch(Exception& ex) catch(Exception& ex)
{ {
...@@ -619,8 +623,14 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm) ...@@ -619,8 +623,14 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
unideb[Debug::CRIT] << myname << "(IONotifyController::send): " unideb[Debug::CRIT] << myname << "(IONotifyController::send): "
<< conf->oind->getNameById(li->id, li->node) << conf->oind->getNameById(li->id, li->node)
<< " !!(...)" << endl; << " !!(...)" << endl;
} }
if( maxAttemtps>0 && (--li->attempt <= 0) )
{
li = lst.erase(li);
break;
}
li->ref = UniSetObject_i::_nil(); li->ref = UniSetObject_i::_nil();
} }
} }
......
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