updateLoadTask.cancelKey.remove(); updateLoadTask.cancelKey = null;
this.keepAliveTime = keepAliveTime; if(this.timerKey != null) { this.timerKey.remove();
void invalidate(final HttpServerExchange exchange, SessionListener.SessionDestroyedReason reason) { synchronized(SessionImpl.this) { if (timerCancelKey != null) { timerCancelKey.remove();
private void handleSchedule(long timeout) { //no current timeout, clear the expire time if(timeout == -1) { this.expireTime = -1; return; } //calculate the new expire time long newExpireTime = System.currentTimeMillis() + timeout; long oldExpireTime = this.expireTime; this.expireTime = newExpireTime; //if the new one is less than the current one we need to schedule a new timer, so cancel the old one if(newExpireTime < oldExpireTime) { if(handle != null) { handle.remove(); handle = null; } } if(handle == null) { try { handle = WorkerUtils.executeAfter(connection.getIoThread(), this, timeout + FUZZ_FACTOR, TimeUnit.MILLISECONDS); } catch (RejectedExecutionException e) { UndertowLogger.REQUEST_LOGGER.debug("Failed to schedule parse timeout, server is probably shutting down", e); } } }
@Override public void handleEvent(ConduitStreamSourceChannel channel) { try { int res = channel.read(b); if (res != 0) { IoUtils.safeClose(connection); IoUtils.safeClose(additional); key.remove(); } } catch (Exception e) { if (e instanceof IOException) { UndertowLogger.REQUEST_IO_LOGGER.ioException((IOException) e); } else { UndertowLogger.REQUEST_IO_LOGGER.ioException(new IOException(e)); } IoUtils.safeClose(connection); IoUtils.safeClose(additional); key.remove(); } } });
void handleException(IOException e, boolean log) { Messages.conn.logf(RemoteConnection.class.getName(), Logger.Level.TRACE, e, "Connection error detail"); if (log) { Messages.conn.connectionError(e); } final XnioExecutor.Key key = writeListener.heartKey; if (key != null) { key.remove(); } synchronized (getLock()) { IoUtils.safeClose(connection); } final Result<ConnectionHandlerFactory> result = this.result; if (result != null) { result.setException(e); this.result = null; } }
private void handleResumeTimeout() { long timeout = getIdleTimeout(); if (timeout <= 0) { return; } long currentTime = System.currentTimeMillis(); long newExpireTime = currentTime + timeout; boolean shorter = newExpireTime < expireTime; if(shorter && handle != null) { handle.remove(); handle = null; } expireTime = newExpireTime; XnioExecutor.Key key = handle; if (key == null) { handle = WorkerUtils.executeAfter(getWriteThread(), timeoutCommand, timeout, TimeUnit.MILLISECONDS); } }
private void redistributeQueued(HostThreadData hostData) { CallbackHolder callback = hostData.awaitingConnections.poll(); while (callback != null) { if (callback.getTimeoutKey() != null) { callback.getTimeoutKey().remove(); } if (!callback.isCancelled()) { long time = System.currentTimeMillis(); if (callback.getExpireTime() > 0 && callback.getExpireTime() < time) { callback.getCallback().failed(callback.getExchange()); } else { callback.getCallback().queuedRequestFailed(callback.getExchange()); } } callback = hostData.awaitingConnections.poll(); } }
@Override public void run() { if(shutdown || open == 0) { if(timerKey != null) { timerKey.remove(); } return; } if(pooled == null) { pooled = exchange.getConnection().getByteBufferPool().allocate(); pooled.getBuffer().put(":\n".getBytes(StandardCharsets.UTF_8)); pooled.getBuffer().flip(); writeListener.handleEvent(sink); } } }, keepAliveTime, TimeUnit.MILLISECONDS);
public void run() { try { command.run(); } finally { Key o, n; o = current.get(); if (o != this) { n = executeAfter(this, millis, TimeUnit.MILLISECONDS); if (!current.compareAndSet(o, n)) { n.remove(); } } } } }
@Override public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException { long ret = super.writeFinal(srcs, offset, length); handleWriteTimeout(ret); if(!Buffers.hasRemaining(srcs)) { if(handle != null) { handle.remove(); handle = null; } } return ret; }
@Override public void suspendWrites() { sink.suspendWrites(); XnioExecutor.Key handle = this.handle; if(handle != null && !isReadResumed()) { handle.remove(); this.handle = null; } }
@Override public int read(ByteBuffer dst) throws IOException { handleIdleTimeout(); int r = source.read(dst); if(sink.isWriteShutdown() && r == -1) { if(handle != null) { handle.remove(); handle = null; } } return r; }
@Override public long transferTo(long position, long count, FileChannel target) throws IOException { handleIdleTimeout(); long w = source.transferTo(position, count, target); if(sink.isWriteShutdown() && w == -1) { if(handle != null) { handle.remove(); handle = null; } } return w; }
@Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { key.remove(); nextListener.proceed(); } });
private synchronized void destroy() { if (timerCancelKey != null) { timerCancelKey.remove(); } cancelTask = null; }
public boolean remove() { final Key removed = current.getAndSet(this); // removed key should not be null because remove cannot be called before it is populated. assert removed != null; return removed != this && removed.remove(); }
void taskCompleted() { if (state == State.WAITING) { state = State.DONE; if (cancelKey != null) { cancelKey.remove(); } delegate.completed(); } }
@Override public void suspendWrites() { super.suspendWrites(); XnioExecutor.Key handle = this.handle; if(handle != null) { handle.remove(); this.handle = null; } }
@Override public void truncateWrites() throws IOException { super.truncateWrites(); if(handle != null) { handle.remove(); handle = null; } }