[SNMP4J] Another race condition fix for DefaultUdpTransportMapping

Paul Marquis paul at viridity.com
Fri Sep 24 01:32:01 CEST 2010


Thanks for fixing this!

Any idea when there will be an official release with this fix in it?   
I just joined the list, so if you've already discussed when the next  
release will be available, I apologize.

On Sep 23, 2010, at 7:24 PM, Frank Fock wrote:

> Hi Paul,
>
> Thank you for the bug report. If fixed it a bit different:
>
>           try {
>             DatagramSocket socketCopy = socket;
>             if (socketCopy == null) {
>               stop = true;
>               continue;
>             }
>             socketCopy.receive(packet);
>           }
>
> Best regards,
> Frank
>
> On 23.09.2010 23:44, Paul Marquis wrote:
>> Version 1.11.1 of SNMP4J included a fix for a race condition in
>> DefautlUdpTrasnportMapping which caused a NullPointerException.
>> However, there is still one that remains while attempting to read a
>> packet and I see this from time to time.  Below is a patch that fixes
>> the problem for me that I'd like to submit for review.
>>
>> Index: src/org/snmp4j/transport/DefaultUdpTransportMapping.java
>> ===================================================================
>> --- src/org/snmp4j/transport/DefaultUdpTransportMapping.java	 
>> (revision
>> 215)
>> +++ src/org/snmp4j/transport/DefaultUdpTransportMapping.java	(working
>> copy)
>> @@ -337,7 +337,11 @@
>>
>> udpAddress.getPort());
>>           try {
>>             try {
>> -            socket.receive(packet);
>> +            DatagramSocket readingSocket = socket;
>> +            if (readingSocket == null) {
>> +              continue;
>> +            }
>> +            readingSocket.receive(packet);
>>             }
>>             catch (InterruptedIOException iiox) {
>>               if (iiox.bytesTransferred<= 0) {
>>
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> -- 
> AGENT++
> http://www.agentpp.com
> http://www.snmp4j.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list