do {
if (status == SocketStatus.DISCONNECT &&
!processor.isComet()) {
// Do nothing here, just wait for it to get recycled
// Don't do this for Comet we need to generate an end
// event (see BZ 54022)
} else if (processor.isAsync() ||
state == SocketState.ASYNC_END) {
state = processor.asyncDispatch(status);
} else if (processor.isComet()) {
state = processor.event(status);
} else if (processor.isUpgrade()) {
state = processor.upgradeDispatch();
} else {
state = processor.process(socket);
}
if (state != SocketState.CLOSED && processor.isAsync()) {
state = processor.asyncPostProcess();
}
if (state == SocketState.UPGRADING) {
// Get the UpgradeInbound handler
UpgradeInbound inbound = processor.getUpgradeInbound();
// Release the Http11 processor to be re-used
release(socket, processor, false, false);
// Create the light-weight upgrade processor
processor = createUpgradeProcessor(socket, inbound);
inbound.onUpgradeComplete();
}
} while (state == SocketState.ASYNC_END ||
state == SocketState.UPGRADING);
当跳出循环之后,再根据状态值选择release还是longPoll
release收回Http11Processor实例,longPoll则将以socket为key, processor为值放对map中,以做下一步处理。
5、再根据handler的处理结果,来决定下一步的处理。
录为OPEN, UPGRADING, UPGRADED时,则设置launch=true。
if (state == SocketState.OPEN ||
state == SocketState.UPGRADING ||
state == SocketState.UPGRADED){
socket.setKeptAlive(true);
socket.access();
launch = true;
}
6、当状态为LONG,则表示连接还持续,请求还需要再处理。类似于文件上传的这类请求。
if (state == SocketState.LONG) {
socket.access();
waitingRequests.add(socket);
}
7、最终进入finally代码块
当状态为lauch,则需要进一步处理请求。