if (state == SocketState.LONG) {
// In the middle of processing a request/response. Keep the
- // socket associated with the processor.
- connections.put(socket.getSocket(), processor);
-
- if (processor.isAsync()) {
- socket.setAsync(true);
- } else if (processor.comet) {
- ((AprEndpoint) proto.endpoint).getCometPoller().add(
- socket.getSocket().longValue());
- }
+ // socket associated with the processor. Exact requirements
+ // depend on type of long poll
+ longPoll(socket, processor);
} else if (state == SocketState.OPEN){
// In keep-alive but between requests. OK to recycle
// processor. Continue to poll for the next request.
// any other exception or error is odd. Here we log it
// with "ERROR" level, so it will show up even on
// less-than-verbose logs.
- Http11AprProtocol.log.error(
- sm.getString("http11protocol.proto.error"), e);
+ log.error(sm.getString("http11protocol.proto.error"), e);
}
release(socket, processor, true, false);
return SocketState.CLOSED;
// NOOP for APR
}
+ private void longPoll(SocketWrapper<Long> socket,
+ Http11AprProcessor processor) {
+ connections.put(socket.getSocket(), processor);
+
+ if (processor.isAsync()) {
+ socket.setAsync(true);
+ } else if (processor.comet) {
+ ((AprEndpoint) proto.endpoint).getCometPoller().add(
+ socket.getSocket().longValue());
+ }
+ }
+
protected Http11AprProcessor createProcessor() {
Http11AprProcessor processor = new Http11AprProcessor(
proto.getMaxHttpHeaderSize(), (AprEndpoint)proto.endpoint,
if (state == SocketState.LONG) {
// In the middle of processing a request/response. Keep the
- // socket associated with the processor.
- connections.put(socket, processor);
-
- if (processor.isAsync()) {
- socket.setAsync(true);
- } else {
- // Either:
- // - this is comet request
- // - the request line/headers have not been completely
- // read
- SelectionKey key = socket.getSocket().getIOChannel().keyFor(
- socket.getSocket().getPoller().getSelector());
- key.interestOps(SelectionKey.OP_READ);
- ((KeyAttachment) socket).interestOps(
- SelectionKey.OP_READ);
- }
+ // socket associated with the processor. Exact requirements
+ // depend on type of long poll
+ longPoll(socket, processor);
} else if (state == SocketState.OPEN){
// In keep-alive but between requests. OK to recycle
// processor. Continue to poll for the next request.
}
+ private void longPoll(SocketWrapper<NioChannel> socket,
+ Http11NioProcessor processor) {
+ connections.put(socket, processor);
+
+ if (processor.isAsync()) {
+ socket.setAsync(true);
+ } else {
+ // Either:
+ // - this is comet request
+ // - the request line/headers have not been completely
+ // read
+ SelectionKey key = socket.getSocket().getIOChannel().keyFor(
+ socket.getSocket().getPoller().getSelector());
+ key.interestOps(SelectionKey.OP_READ);
+ ((KeyAttachment) socket).interestOps(
+ SelectionKey.OP_READ);
+ }
+ }
+
public Http11NioProcessor createProcessor() {
Http11NioProcessor processor = new Http11NioProcessor(
proto.getMaxHttpHeaderSize(), (NioEndpoint)proto.endpoint,
processor = createProcessor();
}
- initSsl(socket,processor);
+ initSsl(socket, processor);
SocketState state = SocketState.CLOSED;
do {
if (state == SocketState.LONG) {
// In the middle of processing a request/response. Keep the
- // socket associated with the processor.
- connections.put(socket, processor);
+ // socket associated with the processor. Exact requirements
+ // depend on type of long poll
+ longPoll(socket, processor);
} else if (state == SocketState.OPEN){
// In keep-alive but between requests. OK to recycle
// processor. Continue to poll for the next request.
}
+ private void longPoll(SocketWrapper<Socket> socket,
+ Http11Processor processor) {
+ connections.put(socket, processor);
+ }
+
protected Http11Processor createProcessor() {
Http11Processor processor = new Http11Processor(
proto.getMaxHttpHeaderSize(), (JIoEndpoint)proto.endpoint,