private Request request;
public AsyncContextImpl(Request request) {
+ if (log.isDebugEnabled()) {
+ log.debug("AsyncContext created["+request.getRequestURI()+"?"+request.getQueryString()+"]", new DebugException());
+ }
//TODO SERVLET3 - async
this.request = request;
}
@Override
public void complete() {
+ if (log.isDebugEnabled()) {
+ log.debug("AsyncContext Complete Called["+state.get()+"; "+request.getRequestURI()+"?"+request.getQueryString()+"]", new DebugException());
+ }
if (state.get()==AsyncState.COMPLETING) {
//do nothing
- } else if (state.compareAndSet(AsyncState.STARTED, AsyncState.COMPLETING)) {
- // TODO SERVLET3 - async
- doInternalComplete(false);
- } else if (state.compareAndSet(AsyncState.DISPATCHED, AsyncState.COMPLETING)) {
+ } else if (state.compareAndSet(AsyncState.DISPATCHED, AsyncState.COMPLETING) ||
+ state.compareAndSet(AsyncState.STARTED, AsyncState.COMPLETING)) {
// TODO SERVLET3 - async
AtomicBoolean dispatched = new AtomicBoolean(false);
request.getCoyoteRequest().action(ActionCode.ACTION_ASYNC_COMPLETE,dispatched);
@Override
public void dispatch(ServletContext context, String path) {
+ if (log.isDebugEnabled()) {
+ log.debug("AsyncContext Dispatch Called["+state.get()+"; "+path+"; "+request.getRequestURI()+"?"+request.getQueryString()+"]", new DebugException());
+ }
+
// TODO SERVLET3 - async
if (state.compareAndSet(AsyncState.STARTED, AsyncState.DISPATCHING) ||
state.compareAndSet(AsyncState.DISPATCHED, AsyncState.DISPATCHING)) {
if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
- request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
+ request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI()+"?"+request.getQueryString());
request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
request.setAttribute(ASYNC_QUERY_STRING, request.getQueryString());
@Override
public void start(final Runnable run) {
+ if (log.isDebugEnabled()) {
+ log.debug("AsyncContext Start Called["+state.get()+"; "+request.getRequestURI()+"?"+request.getQueryString()+"]", new DebugException());
+ }
+
if (state.compareAndSet(AsyncState.STARTED, AsyncState.DISPATCHING) ||
state.compareAndSet(AsyncState.DISPATCHED, AsyncState.DISPATCHING)) {
// TODO SERVLET3 - async
this.servletResponse = response;
event = new AsyncEvent(this, request, response);
}
-
+ public static class DebugException extends Exception {}
}
//------------------------------------------------------ Constructor
public AccessLogValve() {
- super(false);
+ super(true);
}
// ----------------------------------------------------- Instance Variables
@Override
public void invoke(Request request, Response response) throws IOException,
ServletException {
-
+ final String t1Name = AccessLogValve.class.getName()+".t1";
if (getState().isAvailable() && getEnabled()) {
// Pass this request on to the next valve in our pipeline
long t1 = System.currentTimeMillis();
+ boolean asyncdispatch = request.isAsyncDispatching();
+ if (!asyncdispatch) {
+ request.setAttribute(t1Name, new Long(t1));
+ }
getNext().invoke(request, response);
+ //we're not done with the request
+ if (request.isAsyncDispatching()) {
+ return;
+ } else if (asyncdispatch && request.getAttribute(t1Name)!=null) {
+ t1 = ((Long)request.getAttribute(t1Name)).longValue();
+ }
+
long t2 = System.currentTimeMillis();
long time = t2 - t1;
public SocketState process(SocketWrapper<Socket> socket, SocketStatus status) {
Http11Processor processor = connections.remove(socket);
+ boolean recycle = true;
try {
if (processor == null) {
processor = recycledProcessors.poll();
if (state == SocketState.LONG) {
connections.put(socket, processor);
socket.setAsync(true);
+ recycle = false;
} else {
connections.remove(socket);
socket.setAsync(false);
// if(proto.adapter != null) proto.adapter.recycle();
// processor.recycle();
- processor.action(ActionCode.ACTION_STOP, null);
- recycledProcessors.offer(processor);
+ if (recycle) {
+ processor.action(ActionCode.ACTION_STOP, null);
+ recycledProcessors.offer(processor);
+ }
}
return SocketState.CLOSED;
}