[AGENT++] Threading and replace_value()?

Tomas Tomas2003 at home.se
Wed Mar 7 13:41:52 CET 2007


Hi again

Thanks for your quick answer. It clarified a lot.

I have also a table where I occasionally need to remove/add the rows
from this application thread.
.
 From searching the archives I understand that start_synch() should be used
How does this relate to Mib::lock_mib() ?

(assume you meant Mib::lock_mib when you wrote Mib::lock())

Regards, Tomas

Frank Fock skrev:
> 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
>




More information about the AGENTPP mailing list