Commit 365e4539 authored by Pavel Vainerman's avatar Pavel Vainerman

add ConsumerMaxAttempts property got IONotifyController

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