error = true;
}
- boolean keptAlive = false;
+ boolean keptAlive = socketWrapper.isKeptAlive();
while (started && !error && keepAlive) {
// Parsing the request header
try {
+ //TODO - calculate timeout based on length in queue (System.currentTimeMills() - wrapper.getLastAccess() is the time in queue)
if (keptAlive) {
if (keepAliveTimeout > 0) {
socket.setSoTimeout(keepAliveTimeout);
public void run() {
boolean close = false;
// Process the request from this socket
- if (!setSocketOptions(socket.getSocket())) { //this does a handshake and resets socket value
+ if ( (!socket.isKeptAlive()) && (!setSocketOptions(socket.getSocket())) ) { //this does a handshake and resets socket value
close = true;
- } else if (!handler.process(socket)) {
- close = true;
+ }
+
+ if ( (!close) ) {
+ close = !handler.process(socket);
}
if (close) {
// Close socket
// Ignore
}
} else {
+ socket.setKeptAlive(true);
+ socket.access();
//keepalive connection
+ //TODO - servlet3 check async status, we may just be in a hold pattern
getExecutor().execute(new SocketProcessor(socket));
}
// Finish up this request
protected volatile E socket;
- protected long lastAccess = -1;
- protected boolean currentAccess = false;
+ protected volatile long lastAccess = -1;
+ protected volatile boolean currentAccess = false;
protected long timeout = -1;
protected boolean error = false;
protected long lastRegistered = 0;
protected volatile int keepAliveLeft = 100;
protected boolean async = false;
+ protected boolean keptAlive = false;
public SocketWrapper(E socket) {
reset(socket);
public int getKeepAliveLeft() { return this.keepAliveLeft; }
public void setKeepAliveLeft(int keepAliveLeft) { this.keepAliveLeft = keepAliveLeft;}
public int decrementKeepAlive() { return (--keepAliveLeft);}
-
+ public boolean isKeptAlive() {return keptAlive;}
+ public void setKeptAlive(boolean keptAlive) {this.keptAlive = keptAlive;}
}