Fix defect in DoSFilter where semaphore acquires my be leaked
When trying to release the semaphore in the finally block, 'asyncContext.dispatch()' may throw a "RejectedExecutionException". If this occurs, then the semaphore will never be released. Ultimately the condition will result in all threads blocking to acquire the semaphore as the DoSFilter is continue to be used. https://github.com/eclipse/jetty.project/pull/54 Signed-off-By: jentfoo@gmail.com
This commit is contained in:
parent
8f732a423d
commit
407ca46d94
|
@ -427,25 +427,31 @@ public class DoSFilter implements Filter
|
|||
{
|
||||
if (accepted)
|
||||
{
|
||||
// Wake up the next highest priority request.
|
||||
for (int p = _queues.length - 1; p >= 0; --p)
|
||||
try
|
||||
{
|
||||
AsyncContext asyncContext = _queues[p].poll();
|
||||
if (asyncContext != null)
|
||||
// Wake up the next highest priority request.
|
||||
for (int p = _queues.length - 1; p >= 0; --p)
|
||||
{
|
||||
ServletRequest candidate = asyncContext.getRequest();
|
||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||
if (suspended == Boolean.TRUE)
|
||||
AsyncContext asyncContext = _queues[p].poll();
|
||||
if (asyncContext != null)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Resuming {}", request);
|
||||
candidate.setAttribute(_resumed, Boolean.TRUE);
|
||||
asyncContext.dispatch();
|
||||
break;
|
||||
ServletRequest candidate = asyncContext.getRequest();
|
||||
Boolean suspended = (Boolean)candidate.getAttribute(_suspended);
|
||||
if (suspended == Boolean.TRUE)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Resuming {}", request);
|
||||
candidate.setAttribute(_resumed, Boolean.TRUE);
|
||||
asyncContext.dispatch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_passes.release();
|
||||
finally
|
||||
{
|
||||
_passes.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue