406617 Spin in Request.recylce
Some more cleanups of the loops
This commit is contained in:
parent
e6dc08cf97
commit
0b15aa5a76
|
@ -1325,7 +1325,6 @@ public class HttpParser
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
BufferUtil.clear(buffer);
|
||||
if (isClosed())
|
||||
{
|
||||
|
|
|
@ -238,115 +238,104 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
|||
Thread.currentThread().setName(threadName + " - " + _uri);
|
||||
}
|
||||
|
||||
|
||||
// Loop here to handle async request redispatches.
|
||||
// The loop is controlled by the call to async.unhandle in the
|
||||
// finally block below. Unhandle will return false only if an async dispatch has
|
||||
// already happened when unhandle is called.
|
||||
HttpChannelState.Next next = _state.handling();
|
||||
try
|
||||
while (next==Next.CONTINUE && getServer().isRunning())
|
||||
{
|
||||
|
||||
while (next==Next.CONTINUE && getServer().isRunning())
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_request.setHandled(false);
|
||||
_response.getHttpOutput().reopen();
|
||||
_request.setHandled(false);
|
||||
_response.getHttpOutput().reopen();
|
||||
|
||||
if (_state.isInitial())
|
||||
if (_state.isInitial())
|
||||
{
|
||||
_request.setTimeStamp(System.currentTimeMillis());
|
||||
_request.setDispatcherType(DispatcherType.REQUEST);
|
||||
|
||||
for (HttpConfiguration.Customizer customizer : _configuration.getCustomizers())
|
||||
customizer.customize(getConnector(),_configuration,_request);
|
||||
getServer().handle(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_request.getHttpChannelState().isExpired())
|
||||
{
|
||||
_request.setTimeStamp(System.currentTimeMillis());
|
||||
_request.setDispatcherType(DispatcherType.REQUEST);
|
||||
|
||||
for (HttpConfiguration.Customizer customizer : _configuration.getCustomizers())
|
||||
customizer.customize(getConnector(),_configuration,_request);
|
||||
getServer().handle(this);
|
||||
_request.setDispatcherType(DispatcherType.ERROR);
|
||||
_request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,new Integer(500));
|
||||
_request.setAttribute(RequestDispatcher.ERROR_MESSAGE,"Async Timeout");
|
||||
_request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,_request.getRequestURI());
|
||||
_response.setStatusWithReason(500,"Async Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_request.getHttpChannelState().isExpired())
|
||||
{
|
||||
_request.setDispatcherType(DispatcherType.ERROR);
|
||||
_request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,new Integer(500));
|
||||
_request.setAttribute(RequestDispatcher.ERROR_MESSAGE,"Async Timeout");
|
||||
_request.setAttribute(RequestDispatcher.ERROR_REQUEST_URI,_request.getRequestURI());
|
||||
_response.setStatusWithReason(500,"Async Timeout");
|
||||
}
|
||||
else
|
||||
_request.setDispatcherType(DispatcherType.ASYNC);
|
||||
getServer().handleAsync(this);
|
||||
}
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
if ("ContinuationThrowable".equals(e.getClass().getSimpleName()))
|
||||
LOG.ignore(e);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e instanceof EofException)
|
||||
LOG.debug(e);
|
||||
else
|
||||
LOG.warn(String.valueOf(_uri), e);
|
||||
_state.error(e);
|
||||
_request.setHandled(true);
|
||||
handleException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
next = _state.unhandle();
|
||||
_request.setDispatcherType(DispatcherType.ASYNC);
|
||||
getServer().handleAsync(this);
|
||||
}
|
||||
}
|
||||
if (next==Next.WAIT)
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (threadName != null && LOG.isDebugEnabled())
|
||||
Thread.currentThread().setName(threadName);
|
||||
setCurrentHttpChannel(null);
|
||||
|
||||
if (next==Next.COMPLETE)
|
||||
catch (Error e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_state.completed();
|
||||
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
_response.sendError(404);
|
||||
|
||||
// Complete generating the response
|
||||
_response.complete();
|
||||
|
||||
}
|
||||
catch(EofException e)
|
||||
{
|
||||
if ("ContinuationThrowable".equals(e.getClass().getSimpleName()))
|
||||
LOG.ignore(e);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e instanceof EofException)
|
||||
LOG.debug(e);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
next=Next.RECYCLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (next==Next.RECYCLE)
|
||||
{
|
||||
else
|
||||
LOG.warn(String.valueOf(_uri), e);
|
||||
_state.error(e);
|
||||
_request.setHandled(true);
|
||||
_transport.completed();
|
||||
handleException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
next = _state.unhandle();
|
||||
}
|
||||
|
||||
|
||||
LOG.debug("{} handle exit", this);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
if (threadName != null && LOG.isDebugEnabled())
|
||||
Thread.currentThread().setName(threadName);
|
||||
setCurrentHttpChannel(null);
|
||||
|
||||
if (next==Next.COMPLETE)
|
||||
{
|
||||
try
|
||||
{
|
||||
_state.completed();
|
||||
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
_response.sendError(404);
|
||||
|
||||
// Complete generating the response
|
||||
_response.complete();
|
||||
}
|
||||
catch(EofException e)
|
||||
{
|
||||
LOG.debug(e);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
next=Next.RECYCLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (next==Next.RECYCLE)
|
||||
{
|
||||
_request.setHandled(true);
|
||||
_transport.completed();
|
||||
}
|
||||
|
||||
LOG.debug("{} handle exit", this);
|
||||
|
||||
return next!=Next.WAIT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -288,16 +288,7 @@ public class HttpChannelState
|
|||
_initial=false;
|
||||
_state=State.ASYNCWAIT;
|
||||
scheduleTimeout();
|
||||
if (_state==State.ASYNCWAIT)
|
||||
return Next.WAIT;
|
||||
else if (_state==State.COMPLETECALLED)
|
||||
{
|
||||
_state=State.COMPLETING;
|
||||
return Next.COMPLETE;
|
||||
}
|
||||
_initial=false;
|
||||
_state=State.REDISPATCHED;
|
||||
return Next.CONTINUE;
|
||||
return Next.WAIT;
|
||||
|
||||
case REDISPATCHING:
|
||||
_initial=false;
|
||||
|
|
Loading…
Reference in New Issue