private void doRun() { // Process the request from this socket if (socket.getSocket() == null) { // Closed in another thread return; } SocketState state = handler.process(socket, status); if (state == Handler.SocketState.CLOSED) { // Close socket and pool closeSocket(socket.getSocket().longValue()); socket.reset(null, 1); } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.isAsync()) { waitingRequests.add(socket); } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN_READ); getExecutor().execute(proc); } } }
while (sockets.hasNext()) { SocketWrapper<Long> socket = sockets.next(); if (socket.isAsync()) { long access = socket.getLastAccess(); if (socket.getTimeout() > 0 && (now-access)>socket.getTimeout()) { processSocket(socket, SocketStatus.TIMEOUT, true);
public NioServletInputStream(SocketWrapper<NioChannel> wrapper, NioSelectorPool pool) { this.channel = wrapper.getSocket(); this.pool = pool; }
serverSocketFactory.handshake(socket.getSocket()); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); socket.getSocket().close(); } catch (IOException e) { socket.setKeptAlive(true); socket.access(); launch = true; } else if (state == SocketState.LONG) { socket.access(); waitingRequests.add(socket);
SocketWrapper<Long> socket = sockets.next(); if (socket.async) { long access = socket.getLastAccess(); if (socket.getTimeout() > 0 && (now-access)>socket.getTimeout()) { processSocketAsync(socket,SocketStatus.TIMEOUT);
keptAlive = false; } else { keptAlive = socketWrapper.isKeptAlive(); socketWrapper.setKeepAliveLeft(0); keepAlive = false; } else if (maxKeepAliveRequests > 0 && socketWrapper.decrementKeepAlive() <= 0) { keepAlive = false;
if (setSocketOptions(socket.getSocket().longValue())) { getPoller().add(socket.getSocket().longValue(), false); } else { destroySocket(socket.getSocket().longValue()); socket = null; if (!setSocketOptions(socket.getSocket().longValue())) { destroySocket(socket.getSocket().longValue()); socket = null; return; if (state == Handler.SocketState.CLOSED) { destroySocket(socket.getSocket().longValue()); socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.async) { waitingRequests.add(socket);
if (inputBuffer.lastValid == 0 && socket.getLastAccess() > -1) { int firstReadTimeout; if (keepAliveTimeout == -1) { } else { long queueTime = System.currentTimeMillis() - socket.getLastAccess(); socket.getSocket().setSoTimeout(firstReadTimeout); if (!inputBuffer.fill()) { throw new EOFException(sm.getString("iib.eof.error")); socket.getSocket().setSoTimeout(endpoint.getSoTimeout());
if (setSocketOptions(socket.getSocket().longValue())) { getPoller().add(socket.getSocket().longValue(), getSoTimeout(), true, false); } else { closeSocket(socket.getSocket().longValue()); socket = null; if (!setSocketOptions(socket.getSocket().longValue())) { closeSocket(socket.getSocket().longValue()); socket = null; return; if (state == Handler.SocketState.CLOSED) { closeSocket(socket.getSocket().longValue()); socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.isAsync()) { waitingRequests.add(socket);
inputBuffer.setInputStream(socket.getSocket().getInputStream()); outputBuffer.setOutputStream(socket.getSocket().getOutputStream()); keepAlive = true; int keepAliveLeft = maxKeepAliveRequests>0?socketWrapper.decrementKeepAlive():-1; socket.getSocket().setSoTimeout(soTimeout); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); boolean keptAlive = socketWrapper.isKeptAlive(); socket.getSocket().setSoTimeout(keepAliveTimeout); socket.getSocket().setSoTimeout(soTimeout); keptAlive = true; if (disableUploadTimeout) { socket.getSocket().setSoTimeout(soTimeout); } else { socket.getSocket().setSoTimeout(connectionUploadTimeout);
@Override protected boolean handleIncompleteRequestLineRead() { // Haven't finished reading the request so keep the socket // open openSocket = true; // Check to see if we have read any of the request line yet if (inputBuffer.getParsingRequestLinePhase() < 2) { if (socket.getLastAccess() > -1 || keptAlive) { // Haven't read the request line and have previously processed a // request. Must be keep-alive. Make sure poller uses keepAlive. socket.setTimeout(endpoint.getKeepAliveTimeout()); } } else { // Started to read request line. Need to keep processor // associated with socket readComplete = false; // Make sure poller uses soTimeout from here onwards socket.setTimeout(endpoint.getSoTimeout()); } if (endpoint.isPaused()) { // 503 - Service unavailable response.setStatus(503); adapter.log(request, response, 0); error = true; } else { return true; } return false; }
SocketWrapper<Socket> wrapper = new SocketWrapper<Socket>(socket); wrapper.setKeepAliveLeft(getMaxKeepAliveRequests());
processor.setSSLSupport( proto.sslImplementation.getSSLSupport( socket.getSocket())); } else { processor.setSSLSupport(null); SocketState state = socket.isAsync()?processor.asyncDispatch(status):processor.process(socket); if (state == SocketState.LONG) { connections.put(socket, processor); socket.setAsync(true); } else { connections.remove(socket); socket.setAsync(false); recycledProcessors.offer(processor);
@Override protected void longPoll(SocketWrapper<Long> socket, Processor<Long> processor) { if (processor.isAsync()) { // Async socket.setAsync(true); } else if (processor.isComet()) { // Comet if (proto.endpoint.isRunning()) { socket.setComet(true); ((AprEndpoint) proto.endpoint).getPoller().add( socket.getSocket().longValue(), proto.endpoint.getSoTimeout(), true, false); } else { // Process a STOP directly ((AprEndpoint) proto.endpoint).processSocket( socket.getSocket().longValue(), SocketStatus.STOP); } } else { // Upgraded Poller p = ((AprEndpoint) proto.endpoint).getPoller(); if (p == null) { // Connector has been stopped release(socket, processor, true, false); } else { p.add(socket.getSocket().longValue(), -1, true, false); } } }
status == SocketStatus.TIMEOUT) { SocketWrapper<Long> wrapper = new SocketWrapper<Long>(Long.valueOf(socket)); SocketEventProcessor proc = new SocketEventProcessor(wrapper, status);
S socket = wrapper.getSocket(); if (socket == null) { wrapper.setAsync(false); wrapper, httpUpgradeHandler); wrapper.setUpgraded(true); dispatches = wrapper.getIteratorAndClearDispatches();
public UpgradeNioProcessor(SocketWrapper<NioChannel> wrapper, UpgradeInbound upgradeInbound, NioSelectorPool pool) { super(upgradeInbound); wrapper.setTimeout(upgradeInbound.getReadTimeout()); this.nioChannel = wrapper.getSocket(); this.pool = pool; this.maxRead = nioChannel.getBufHandler().getReadBuffer().capacity(); this.maxWrite = nioChannel.getBufHandler().getWriteBuffer().capacity(); }
SocketWrapper<Socket> wrapper = new SocketWrapper<>(socket); wrapper.setKeepAliveLeft(getMaxKeepAliveRequests()); wrapper.setSecure(isSSLEnabled());
public void access() { access(System.currentTimeMillis()); } public void access(long access) { lastAccess = access; }