[AGENT++] Threading and replace_value()?

Frank Fock fock at agentpp.com
Tue Mar 6 10:38:55 CET 2007


Hi Tomas,

You need to lock tables and leafs manually
to update them from outside the class (i.e.,
updating outside the scope of a processed
request).

AGENT++ locks in two stages:

(1) While searching the target MibEntry,
Mib::lock is called.

(2) After the MibEntry is fetched it is
locked (by MibEntry::lock) and the lock of
the Mib instance is then released.

To avoid deadlocks, you need to do the same
steps when you update a MibEntry externally.

When you have an agent that does not dynamically
change its registration (add/remove MibEntries)
then locking Mib is not necessary, but I would
do it anyway, just to be prepared when the design
changes.

Best regards,
Frank

Tomas wrote:
> Hi
> 
> I'm trying to understand the threading in the agent++.
> 
> I have an application that has a thread that will set new values in the
> mib every now and then by calling replace_value/set_value (OctetStr) in 
> the MibLeafs.
> There is of course snmp-request thread taking care of all the incoming
> snmp requests will calls to requestList->receive(timeout); 
> pMib->process_request() etc.
> 
> I seems from the code that set_value() method in a MibLeaf is not thread 
> safe if
> I use an other thread to update the values as well.
> 
> How to proceed? Is there an other methods or is there a sync mechanism 
> that could be used?
> What are the options and how should it be done?
> 
> Regards,  Tomas
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/agentpp

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the AGENTPP mailing list