looneyapurv / 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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 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 9 years ago
https://java.net/jira/browse/JSIP-499

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