[AGENT++] Patch to fix Mib::cleanup() and prevent possible deadlock

Frank Fock fock at agentpp.com
Mon Dec 15 01:07:46 CET 2014


Hi Claus,

The "deadlock" if you insert the sleep or breakpoint at that
position is expected behavior, because the lock_mib
upwards in the stack will block any access to the MIB.
That does not explain anything.

The issue with the genErr on the NET-SNMP master
can be something completely different.

Best regards,
Frank

Am 14.12.2014 21:17, schrieb Claus Klein:
> Hi Frank,
>
> it happens only after an error. But it can be forced with a breakpoint 
> or sleep() at the update() function like this:
>
> voidnetSnmpHostsEntry::update(Request* req)
> {
> // This table needs to be updated.
> //--AgentGen BEGIN=netSnmpHostsEntry::update
> static unsigned long currentRequest = 0;
> static time_t lastUpdate = 0;
> time_tcurrentTime = time(NULL);
>
> if ((currentTime - lastUpdate) < 3) {
> return;
>   }
>
> if (currentRequest == req->get_request_id()) {
> return;
>   }
>   currentRequest = req->get_request_id();
>   lastUpdate = time(NULL);
>
> //====================================
> start_synch();
> //====================================
>
> if(netSnmpExampleSleeper::instance) {
> long l = 0;
> netSnmpExampleSleeper::instance->get_value(l);
> if (l > 0) sleep(l);
>   }
> // …
>
> or after an gen error at net-snmp master agent like this:
>
> *+ snmpset -r0 -t10 -v3 -u unsecureUser -n subagent localhost:4700 
> 'netSnmpHostRowStatus."test2"' = active*
> *NET-SNMP-EXAMPLES-MIB::netSnmpHostRowStatus.\"test2\" = INTEGER: 
> active(1)*
> *+ snmptable -Cib -r0 -t10 -v3 -u unsecureUser -n subagent 
> localhost:4700 netSnmpHostsTable*
> *SNMP table: NET-SNMP-EXAMPLES-MIB::netSnmpHostsTable*
>
> *            index AddressType Address     Storage RowStatus*
> *        \"nmsv6\"   ipv6 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 
> 00 01 " nonVolatile    active*
> *        \"test2\"   ipv4                                     "7F 00 
> 00 02 " nonVolatile    active*
> *    \"localhost\"   ipv6 "00 00 00 00 00 00 00 00 00 00 00 00 00 00 
> 00 01 " nonVolatile    active*
> *\"broadcasthost\"   ipv4                                     "FF FF 
> FF FF " nonVolatile    active*
> *+ snmpset -r0 -t10 -v3 -u unsecureUser -n subagent localhost:4700 
> 'netSnmpHostRowStatus."test2"' = destroy*
> *Error in packet.*
> *Reason: (genError) A general failure occured*
> *+ echo 'ERROR: should not happen!'*
> *ERROR: should not happen!*
> *+ snmptable -Cib -r0 -t10 -v3 -u unsecureUser -n subagent 
> localhost:4700 netSnmpHostsTable*
> *Timeout: No Response from localhost:4700*
> *Claus-MacBook-Pro:AgentPro clausklein$ *
> *
> *
> *This result in:*
>
> Best regards,
> Claus
>
> On 12.12.2014, at 00:53, Frank Fock <fock at agentpp.com 
> <mailto:fock at agentpp.com>> wrote:
>
>> Hi Claus,
>>
>> From my point of view your patch does not fix the root cause.
>> Normally, a  Mib::cleanup should never get into a deadlock
>> because it first locks the Mib and then single objects.
>> Since all the other AGENT++ and AgentX++ code  uses the
>> same locking scheme, a dead lock should not happen.
>>
>> If it happens though, then some other code does not implement
>> the locking scheme properly. So I will have a look at the
>> timeout thing in process_request() which seems to be
>> prerequisite for the deadlock and therefore I might be able
>> to find the root cause there.
>>
>> Best regards,
>> Frank
>

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the AGENTPP mailing list