412318 HttpChannel fix multiple calls to _transport.completed() if handle() is called multiple times while the channel is COMPLETED

This commit is contained in:
Thomas Becker 2013-07-05 12:02:52 +02:00
parent 5d1225b60e
commit 2d911612a0
2 changed files with 10 additions and 18 deletions

View File

@ -235,8 +235,6 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
public boolean handle() public boolean handle()
{ {
LOG.debug("{} handle enter", this); LOG.debug("{} handle enter", this);
if(_state.isCompleted())
return false;
setCurrentHttpChannel(this); setCurrentHttpChannel(this);
@ -332,16 +330,11 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
} }
finally finally
{ {
next=Next.RECYCLE; _request.setHandled(true);
_transport.completed();
} }
} }
if (next==Next.RECYCLE)
{
_request.setHandled(true);
_transport.completed();
}
LOG.debug("{} handle exit, result {}", this, next); LOG.debug("{} handle exit, result {}", this, next);
return next!=Next.WAIT; return next!=Next.WAIT;

View File

@ -71,13 +71,12 @@ public class HttpChannelState
COMPLETING, // Request is completable COMPLETING, // Request is completable
COMPLETED // Request is complete COMPLETED // Request is complete
} }
public enum Next public enum Next
{ {
CONTINUE, // Continue handling the channel CONTINUE, // Continue handling the channel
WAIT, // Wait for further events WAIT, // Wait for further events
COMPLETE, // Complete the channel COMPLETE // Complete the channel
RECYCLE, // Channel is completed
} }
private final HttpChannel<?> _channel; private final HttpChannel<?> _channel;
@ -190,12 +189,12 @@ public class HttpChannelState
case COMPLETING: case COMPLETING:
return Next.COMPLETE; return Next.COMPLETE;
case ASYNCWAIT: case ASYNCWAIT:
return Next.WAIT; return Next.WAIT;
case COMPLETED: case COMPLETED:
return Next.RECYCLE; return Next.WAIT;
case REDISPATCH: case REDISPATCH:
_state=State.REDISPATCHED; _state=State.REDISPATCHED;
@ -325,7 +324,7 @@ public class HttpChannelState
_event.setDispatchTarget(context,path); _event.setDispatchTarget(context,path);
_dispatched=true; _dispatched=true;
break; break;
default: default:
throw new IllegalStateException(this.getStatusString()); throw new IllegalStateException(this.getStatusString());
} }
@ -393,7 +392,7 @@ public class HttpChannelState
break; break;
} }
} }
scheduleDispatch(); scheduleDispatch();
} }
@ -528,7 +527,7 @@ public class HttpChannelState
return _expired; return _expired;
} }
} }
public boolean isInitial() public boolean isInitial()
{ {
synchronized(this) synchronized(this)