407075 Do not dispatch from complete
Call HttpChannel.handle directly from thread calling complete
This commit is contained in:
parent
215f3f1f56
commit
98d260dd92
|
@ -405,7 +405,7 @@ public class HttpChannelState
|
|||
public void complete()
|
||||
{
|
||||
// just like resume, except don't set _dispatched=true;
|
||||
boolean dispatch;
|
||||
boolean handle;
|
||||
synchronized (this)
|
||||
{
|
||||
switch(_state)
|
||||
|
@ -421,7 +421,7 @@ public class HttpChannelState
|
|||
|
||||
case ASYNCWAIT:
|
||||
_state=State.COMPLETECALLED;
|
||||
dispatch=!_expired;
|
||||
handle=!_expired;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -429,10 +429,14 @@ public class HttpChannelState
|
|||
}
|
||||
}
|
||||
|
||||
if (dispatch)
|
||||
if (handle)
|
||||
{
|
||||
cancelTimeout();
|
||||
scheduleDispatch();
|
||||
ContextHandler handler=getContextHandler();
|
||||
if (handler!=null)
|
||||
handler.handle(_channel);
|
||||
else
|
||||
_channel.handle();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +603,11 @@ public class HttpChannelState
|
|||
{
|
||||
final AsyncContextEvent event=_event;
|
||||
if (event!=null)
|
||||
return ((Context)event.getServletContext()).getContextHandler();
|
||||
{
|
||||
Context context=((Context)event.getServletContext());
|
||||
if (context!=null)
|
||||
return context.getContextHandler();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -458,7 +458,9 @@ public class StatisticsHandlerTest
|
|||
{
|
||||
final long dispatchTime = 10;
|
||||
final AtomicReference<AsyncContext> asyncHolder = new AtomicReference<>();
|
||||
final CyclicBarrier barrier[] = {new CyclicBarrier(2), new CyclicBarrier(2), new CyclicBarrier(2)};
|
||||
final CyclicBarrier barrier[] = {new CyclicBarrier(2), new CyclicBarrier(2)};
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
_statsHandler.setHandler(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
|
@ -540,7 +542,7 @@ public class StatisticsHandlerTest
|
|||
{
|
||||
try
|
||||
{
|
||||
barrier[2].await();
|
||||
latch.countDown();
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
|
@ -550,7 +552,7 @@ public class StatisticsHandlerTest
|
|||
long requestTime = 20;
|
||||
Thread.sleep(requestTime);
|
||||
asyncHolder.get().complete();
|
||||
barrier[2].await();
|
||||
latch.await();
|
||||
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(0, _statsHandler.getRequestsActive());
|
||||
|
|
Loading…
Reference in New Issue