422703 Support reentrant HttpChannel and HttpConnection
This commit is contained in:
parent
1b30b0f9a8
commit
9c013b723b
|
@ -78,9 +78,14 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
||||||
return __currentChannel.get();
|
return __currentChannel.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setCurrentHttpChannel(HttpChannel<?> channel)
|
protected static HttpChannel<?> setCurrentHttpChannel(HttpChannel<?> channel)
|
||||||
{
|
{
|
||||||
|
HttpChannel<?> last=__currentChannel.get();
|
||||||
|
if (channel==null)
|
||||||
|
__currentChannel.remove();
|
||||||
|
else
|
||||||
__currentChannel.set(channel);
|
__currentChannel.set(channel);
|
||||||
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AtomicBoolean _committed = new AtomicBoolean();
|
private final AtomicBoolean _committed = new AtomicBoolean();
|
||||||
|
@ -246,7 +251,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
||||||
{
|
{
|
||||||
LOG.debug("{} handle enter", this);
|
LOG.debug("{} handle enter", this);
|
||||||
|
|
||||||
setCurrentHttpChannel(this);
|
final HttpChannel<?>last = setCurrentHttpChannel(this);
|
||||||
|
|
||||||
String threadName = null;
|
String threadName = null;
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
|
@ -255,11 +260,13 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
||||||
Thread.currentThread().setName(threadName + " - " + _uri);
|
Thread.currentThread().setName(threadName + " - " + _uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpChannelState.Action action = _state.handling();
|
||||||
|
try
|
||||||
|
{
|
||||||
// Loop here to handle async request redispatches.
|
// Loop here to handle async request redispatches.
|
||||||
// The loop is controlled by the call to async.unhandle in the
|
// 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
|
// finally block below. Unhandle will return false only if an async dispatch has
|
||||||
// already happened when unhandle is called.
|
// already happened when unhandle is called.
|
||||||
HttpChannelState.Action action = _state.handling();
|
|
||||||
loop: while (action.ordinal()<HttpChannelState.Action.WAIT.ordinal() && getServer().isRunning())
|
loop: while (action.ordinal()<HttpChannelState.Action.WAIT.ordinal() && getServer().isRunning())
|
||||||
{
|
{
|
||||||
boolean error=false;
|
boolean error=false;
|
||||||
|
@ -371,9 +378,13 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
setCurrentHttpChannel(null);
|
||||||
if (threadName != null && LOG.isDebugEnabled())
|
if (threadName != null && LOG.isDebugEnabled())
|
||||||
Thread.currentThread().setName(threadName);
|
Thread.currentThread().setName(threadName);
|
||||||
setCurrentHttpChannel(null);
|
}
|
||||||
|
|
||||||
if (action==Action.COMPLETE)
|
if (action==Action.COMPLETE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,9 +69,14 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
return __currentConnection.get();
|
return __currentConnection.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setCurrentConnection(HttpConnection connection)
|
protected static HttpConnection setCurrentConnection(HttpConnection connection)
|
||||||
{
|
{
|
||||||
|
HttpConnection last=__currentConnection.get();
|
||||||
|
if (connection==null)
|
||||||
|
__currentConnection.remove();
|
||||||
|
else
|
||||||
__currentConnection.set(connection);
|
__currentConnection.set(connection);
|
||||||
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpConfiguration getHttpConfiguration()
|
public HttpConfiguration getHttpConfiguration()
|
||||||
|
@ -182,7 +187,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
{
|
{
|
||||||
LOG.debug("{} onFillable {}", this, _channel.getState());
|
LOG.debug("{} onFillable {}", this, _channel.getState());
|
||||||
|
|
||||||
setCurrentConnection(this);
|
final HttpConnection last=setCurrentConnection(this);
|
||||||
int filled=Integer.MAX_VALUE;
|
int filled=Integer.MAX_VALUE;
|
||||||
boolean suspended=false;
|
boolean suspended=false;
|
||||||
try
|
try
|
||||||
|
@ -246,7 +251,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
setCurrentConnection(null);
|
setCurrentConnection(last);
|
||||||
if (!suspended && getEndPoint().isOpen() && getEndPoint().getConnection()==this)
|
if (!suspended && getEndPoint().isOpen() && getEndPoint().getConnection()==this)
|
||||||
{
|
{
|
||||||
fillInterested();
|
fillInterested();
|
||||||
|
|
Loading…
Reference in New Issue