private ByteBuffer combine(ByteBuffer cachedToProcessLaterData, ByteBuffer encryptedData) { int size = cachedToProcessLaterData.remaining()+encryptedData.remaining(); ByteBuffer nextBuffer = pool.nextBuffer(size); nextBuffer.put(cachedToProcessLaterData); nextBuffer.put(encryptedData); nextBuffer.flip(); pool.releaseBuffer(cachedToProcessLaterData); pool.releaseBuffer(encryptedData); return nextBuffer; }
public AsyncSSLEngine2Impl(String loggingId, SSLEngine engine, BufferPool pool, SslListener listener) { if(listener == null) throw new IllegalArgumentException("listener cannot be null"); this.pool = pool; this.listener = listener; ByteBuffer cachedOutBuffer = pool.nextBuffer(engine.getSession().getApplicationBufferSize()); this.mem = new SslMementoImpl(loggingId, engine, cachedOutBuffer); }
private synchronized List<CompletableFuture<Void>> failAllWritesInQueue() { List<CompletableFuture<Void>> copy = new ArrayList<>(); while(!dataToBeWritten.isEmpty()) { WriteInfo runnable = dataToBeWritten.remove(); ByteBuffer buffer = runnable.getBuffer(); buffer.position(buffer.limit()); //mark buffer read before releasing it pool.releaseBuffer(buffer); copy.add(runnable.getPromise()); } waitingBytesCounter = 0; return copy; }
ByteBuffer engineToSocketData = pool.nextBuffer(sslEngine.getSession().getPacketBufferSize());
@Override public CompletableFuture<Void> write(ByteBuffer b) { if(b.remaining() == 0) throw new IllegalArgumentException("buffer has no data"); else if(!selMgr.isRunning()) throw new IllegalStateException(this+"ChannelManager must be running and is stopped"); else if(channelState == ChannelState.CLOSED) { if(isRemoteEndInitiateClose) throw new NioClosedChannelException(this+"Client cannot write after the remote end closed the socket"); else throw new NioClosedChannelException(this+"Your Application cannot write after YOUR Application closed the socket"); } else if(channelState != ChannelState.CONNECTED) { throw new NioException("The Channel is not connected yet"); } apiLog.trace(()->this+"Basic.write"); return writeSynchronized(b) .thenApply(v -> { pool.releaseBuffer(b); return null; }); }
ByteBuffer engineToSocketData = pool.nextBuffer(sslEngine.getSession().getPacketBufferSize()); pool.releaseBuffer(buffer);
BasChannelImpl channel = (BasChannelImpl)info.getChannel(); ByteBuffer chunk = pool.nextBuffer(1024);
if(cachedBuffer != null) { ByteBuffer newBuf = pool.nextBuffer(cachedBuffer.remaining()+b.remaining()); newBuf.put(cachedBuffer); newBuf.put(b); newBuf.flip(); pool.releaseBuffer(b); //release b that is now in the newBuf pool.releaseBuffer(cachedBuffer); //release cached buffer that is now in newBuf b = newBuf;
ByteBuffer newCachedOut = pool.nextBuffer(sslEngine.getSession().getApplicationBufferSize()); mem.setCachedOut(newCachedOut); } else { pool.releaseBuffer(encryptedData);