int keepaliveThreadRead(ReadStream is,long timeoutConn) throws IOException {
  if (isClosed()) {
    return -1;
  }
  int available=is.availableBuffer();
  if (available > 0) {
    return available;
  }
  long timeout=Math.min(getKeepaliveTimeout(),getSocketTimeout());
  if (timeoutConn > 0) {
    timeout=Math.min(timeout,timeoutConn);
  }
  int keepaliveThreadCount=_keepaliveThreadCount.incrementAndGet();
  try {
    int result;
    if (isKeepaliveAsyncEnabled() && _pollManager != null) {
      timeout=Math.min(timeout,getBlockingTimeoutForPoll());
      if (keepaliveThreadCount > 32) {
        if (isAsyncThrottle()) {
          return 0;
        }
 else {
          timeout=Math.min(timeout,100);
        }
      }
    }
    if (timeout <= 0) {
      return 0;
    }
    _keepaliveThreadMeter.start();
    try {
      result=is.fillWithTimeout(timeout);
    }
  finally {
      _keepaliveThreadMeter.end();
    }
    if (isClosed()) {
      return -1;
    }
    return result;
  }
 catch (  IOException e) {
    if (isClosed()) {
      log.log(Level.FINEST,e.toString(),e);
      return -1;
    }
    throw e;
  }
 finally {
    _keepaliveThreadCount.decrementAndGet();
  }
}

int keepaliveThreadRead ( ReadStream is , long timeoutConn ) throws IOException { if ( isClosed ( ) ) { return - 1 ; } int available = is . availableBuffer ( ) ; if ( available > 0 ) { return available ; } long timeout = Math . min ( getKeepaliveTimeout ( ) , getSocketTimeout ( ) ) ; if ( timeoutConn > 0 ) { timeout = Math . min ( timeout , timeoutConn ) ; } int keepaliveThreadCount = _keepaliveThreadCount . incrementAndGet ( ) ; try { int result ; if ( isKeepaliveAsyncEnabled ( ) && _pollManager != null ) { timeout = Math . min ( timeout , getBlockingTimeoutForPoll ( ) ) ; if ( keepaliveThreadCount > 32 ) { if ( isAsyncThrottle ( ) ) { return 0 ; } else { timeout = Math . min ( timeout , 100 ) ; } } } if ( timeout <= 0 ) { return 0 ; } _keepaliveThreadMeter . start ( ) ; try { result = is . fillWithTimeout ( timeout ) ; } finally { _keepaliveThreadMeter . end ( ) ; } if ( isClosed ( ) ) { return - 1 ; } return result ; } catch ( IOException e ) { if ( isClosed ( ) ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; return - 1 ; } throw e ; } finally { _keepaliveThreadCount . decrementAndGet ( ) ; } }
reads data from a keepalive connection
