Ok, here is possible patch but I did't test it at all. Transmitter is changed so it calls pdu.transmit() outside of synchronize block so the transmit sequence don't capture the Transmitter instance monitor. The AbstractSnmpContext.destroy() is changed so it uses new flag which prevents new PDUs to be added tothe context after the destroy is called and awaits for known PDUs to get answers.
I'm still running the tests but while this fixes the deadlock there is the hidden issue with the lib architecture in there related to this deadlock. This deadlock happens in the case when the context was closed before the PDU was sent so if the deadlock will be fixed there will still be the issue: in some cases some PDUs will not be sent to devices due to race condition because the required context is destroyed before the actual data send happens.
I'm still running the tests but while this fixes the deadlock there is the hidden issue with the lib architecture in there related to this deadlock. This deadlock happens in the case when the context was closed before the PDU was sent so if the deadlock will be fixed there will still be the issue: in some cases some PDUs will not be sent to devices due to race condition where the required context is destroyed before the actual data send happens.
If someone interested in the fix I have made one for myself (sorry I can't make the proper patch) and I'm still testing it. There are changes in 2 methods in class: uk.co.westhawk.snmp.stack.Transmitter public void run() { while (me != null) { Pdu cachedPdu = sit(); if (cachedPdu != null) { cachedPdu.transmit(); synchronized (this) { if( pdu == cachedPdu ) { // I will say this only once.... pdu = null; } } } } } synchronized Pdu sit() { while ((me != null) && (pdu == null)) { try { wait(); } catch...
If someone interested in the fix I have made one for myself (sorry I can't make the proper patch) and I'm still testing it. There are changes in 2 methods in class: uk.co.westhawk.snmp.stack.Transmitter public void run() { while (me != null) { Pdu cachedPdu = sit(); if (cachedPdu != null) { cachedPdu.transmit(); synchronized (this) { if( pdu == cachedPdu ) { // I will say this only once.... pdu = null; } } } } synchronized Pdu sit() { while ((me != null) && (pdu == null)) { try { wait(); } catch...