amitpahune / jain-sip

Automatically exported from code.google.com/p/jain-sip
0 stars 0 forks source link

ParseException in NioPipelineParser can starve out all threads quickly, causing a complete shutdown of message processing #160

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Look at : src/gov/nist/javax/sip/parser/NioPipelineParser.run() and how a 
semaphore is acquired but if:

parsedSIPMessage = smp.parseSIPMessage(unparsedMessage.lines.getBytes(), false, 
false, null)

throws a ParseException, the semaphore isn't released when the exception code 
returns. This caused several complete outages for us until we found the issue 
and fixed it.

What we have is:

try { 
parsedSIPMessage = smp.parseSIPMessage(unparsedMessage.lines.getBytes(), false, 
false, null); 
if(unparsedMessage.body.length > 0) { 
parsedSIPMessage.setMessageContent(unparsedMessage.body); 
} 
} catch (ParseException e) { 
logger.logError("Problem parsing message " + unparsedMessage); 
messagesForCallID.poll(); // move on to the next one 
semaphore.release(); // <----- THE FIX 
return; 
}

where sempahore.release() is the actual change.

Also, you completely ignore the result of trying to acquire the semaphore. If 
there is an InterruptedException you just move on and also if you fail to 
acquire the semaphore in the 30 second timeout you move on too. Hence, no 
semaphore acquired which I can only guess will lead to some really nasty 
concurrency bugs. At least it looks like it...

Original issue reported on code.google.com by jean.deruelle on 24 Apr 2015 at 10:59

GoogleCodeExporter commented 8 years ago
https://java.net/jira/browse/JSIP-499

Original comment by jean.deruelle on 24 Apr 2015 at 11:04

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 1c09fd8d3f61.

JSIP-499

Fix
(cherry picked from commit 33a99c9196e7dab88d353cfd94bad560e942583c)

Original comment by jean.der...@telestax.com on 19 Jun 2015 at 3:05

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 19 Jun 2015 at 3:06