diff options
author | Mike Jensen | 2015-10-01 15:32:19 +0000 |
---|---|---|
committer | Greg Wilkins | 2015-10-12 21:46:25 +0000 |
commit | 5b0427f9ccd56692f8347b7e6a366c1e202cf61b (patch) | |
tree | 44e87500cec34786834723fea16ee30b68c6cbaa /jetty-servlets/src | |
parent | ff8c932b0f92acc2fc6b2ec4227f2645a50b504f (diff) | |
download | org.eclipse.jetty.project-5b0427f9ccd56692f8347b7e6a366c1e202cf61b.tar.gz org.eclipse.jetty.project-5b0427f9ccd56692f8347b7e6a366c1e202cf61b.tar.xz org.eclipse.jetty.project-5b0427f9ccd56692f8347b7e6a366c1e202cf61b.zip |
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
Diffstat (limited to 'jetty-servlets/src')
-rw-r--r-- | jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java index fad67d2721..8a13382865 100644 --- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java +++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/DoSFilter.java @@ -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(); + } } } } |