use of com.generallycloud.baseio.component.ssl.SslHandler in project baseio by generallycloud.
the class AbstractChannelFuture method wrapSSL.
private void wrapSSL(SocketChannel channel) throws IOException {
// FIXME 部分情况下可以不在业务线程做wrapssl
ByteBuf old = this.buf;
SslHandler handler = channel.getSslHandler();
try {
this.buf = handler.wrap(channel, old);
this.buf.nioBuffer();
} finally {
ReleaseUtil.release(old);
}
}
use of com.generallycloud.baseio.component.ssl.SslHandler 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