use of com.generallycloud.baseio.protocol.SslFuture in project baseio by generallycloud.
the class SslChannelByteBufReader method accept.
@Override
public void accept(SocketChannel channel, ByteBuf buffer) throws Exception {
for (; ; ) {
if (!buffer.hasRemaining()) {
return;
}
SslFuture future = channel.getSslReadFuture();
boolean setFutureNull = true;
if (future == null) {
future = this.temporary.reset();
setFutureNull = false;
}
try {
if (!future.read(channel, buffer)) {
if (!setFutureNull) {
if (future == this.temporary) {
future = future.copy(channel);
}
channel.setSslReadFuture(future);
}
return;
}
} catch (Throwable e) {
ReleaseUtil.release(future);
channel.setSslReadFuture(null);
if (e instanceof IOException) {
throw (IOException) e;
}
throw new IOException("exception occurred when do decode ssl," + e.getMessage(), e);
}
if (setFutureNull) {
channel.setSslReadFuture(null);
}
SslHandler sslHandler = channel.getSslHandler();
ByteBuf product;
try {
product = sslHandler.unwrap(channel, future.getByteBuf());
} finally {
ReleaseUtil.release(future);
}
if (product == null) {
continue;
}
nextAccept(channel, product);
}
}
Aggregations