[AGENT++] Threading and replace_value()?
Frank Fock
fock at agentpp.com
Wed Mar 7 21:32:32 CET 2007
Hi Thomas,
start_sync is the old name of the same method
which is now called lock(). In the case of
the Mib class, there is also lock_mib()
which I indeed wanted to refer to.
Adding and removing rows needs to be synchronized
in the same way as write access to a table.
Best regards,
Frank
Tomas wrote:
> 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
>>
>
> _______________________________________________
> 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