// Associate the connection with the processor. The next request
// processed by this thread will use either a new or a recycled
// processor.
- if (log.isDebugEnabled()) log.debug("Not recycling ["+processor+"] Comet="+((NioEndpoint.KeyAttachment)socket.getAttachment(false)).getComet());
+ //if (log.isDebugEnabled()) log.debug("Not recycling ["+processor+"] Comet="+((NioEndpoint.KeyAttachment)socket.getAttachment(false)).getComet());
connections.put(socket, processor);
if (processor.comet) {
NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
long now = System.currentTimeMillis();
//don't process timeouts too frequently, but if the selector simply timed out
//then we can check timeouts to avoid gaps
- if ( (now < nextExpiration) && (keyCount>0 || hasEvents) && (!close) ) return;
- nextExpiration = now + (long)socketProperties.getSoTimeout();
+ if ( ((keyCount>0 || hasEvents) ||(now < nextExpiration)) && (!close) ) {
+ return;
+ }
+ long prevExp = nextExpiration; //for logging purposes only
+ nextExpiration = now + socketProperties.getTimeoutInterval();
//timeout
Set<SelectionKey> keys = selector.keys();
int keycount = 0;
cancelledKey(key, SocketStatus.ERROR,false);
}
}//for
- if ( log.isDebugEnabled() ) log.debug("Poller processed "+keycount+" keys through timeout");
+ if ( log.isDebugEnabled() ) log.debug("timeout completed: keys processed="+keycount+"; now="+now+"; nextExpiration="+prevExp+"; "+
+ "keyCount="+keyCount+"; hasEvents="+hasEvents +"; eval="+( (now < prevExp) && (keyCount>0 || hasEvents) && (!close) ));
+
}
}
* Default value is 1
*/
protected int performanceBandwidth = 1;
+
+ /**
+ * Minimum time to pass by before another socket expiration run performs
+ * This avoids unncessary loops over all sockets when the poller is busy
+ */
+ protected long timeoutInterval = 1000;
+
private Socket properties;
public void setProperties(Socket socket) throws SocketException{
this.bufferPool = directBufferPool;
}
+ public void setTimeoutInterval(long toi){
+ this.timeoutInterval = toi;
+ }
+
+ public long getTimeoutInterval(){
+ return timeoutInterval;
+ }
+
}
\ No newline at end of file