[SNMP4J] Multithreaded Agent problem ?

Frank Fock fock at agentpp.com
Sat Jul 22 09:32:53 CEST 2006


Hi J.D.,

It seems that you discovered a bug - probably a regression
(I have not checked that yet).

The code you quoted should look like:

       else {
         logger.debug("RFC3412 ยง7.2.10 - Received PDU is NOT a response 
or " +
                      "internal class message -> unchanged PduHandle = "+
                      sendPduHandle);
       }

Thus, the PDU handle should not be modified. Could you please
verify that this fixes your problem?

Best regards,
Frank

JD Bertron wrote:
> Hey Frank,
> 
> I've been testing with the BaseAgent. I wanted to handle multiple requests
> concurrently so I could see the effect of some queries taking longer than
> others on an different application I wrote. 
> 
> I added a thread pool to my agent (command processor) and it properly
> handles the requests if they come in one at a time. But when one request
> takes longer to handle than others, if another request arrives before it is
> done processing, the first query's response is never sent. 
> 
> I tracked it down to the MPv3.Cache.popEntry which returns null and causes
> MPv3.prepareResponseMessage() to return with SNMP_MP_UNKNOWN_MSGID.
> 
> First, I though my entries were getting GC'd because of the WeakHashMap but
> in fact, it's because the new request gets assigned a 'NONE' PduHandle in
> MPv3.prepareDataElements(). There is even a comment about it in the code:
> 
>  
> 
>         "RFC3412 ?7.2.10 - Received PDU is NOT a response or internal class
> message -> PduHandle := NONE");
> 
>         sendPduHandle.setTransactionID(PduHandle.NONE);
> 
>  
> 
> Because both requests end up with the same key in the cache, only the last
> request that comes in gets a response, since the popEntry will remove the
> state reference and the 'long' request that arrived first ends up failing
> the statereference lookup.
> 
>  
> 
> Is this problem already documented, or am I approaching things the wrong way
> ? 
> 
> And of course your favorite: what do you suggest ?
> 
>  
> 
>  
> 
> J.D. Bertron.
> 
> SFA Charleston. 
> 
> 843-202-2593.
> 
>  
> 
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

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




More information about the SNMP4J mailing list