Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netty connector/container modifications #4387

Merged
merged 7 commits into from
Feb 19, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
available and releaseByteBuf methods added
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Feb 18, 2020
commit 8c7d90cb06e6f5a217c25afd56291dbb7a42092e
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ public int read(byte[] b, int off, int len) throws IOException {
}
buffer.get(b, off, len);
if (rem == len) {
current.release();
current = null;
buffer = null;
releaseByteBuf();
}

return len;
Expand All @@ -90,13 +88,19 @@ public int read() throws IOException {

@Override
public synchronized void close() {
if (current != null) {
current.release();
}

current = null;
buffer = null;
cleanup(true);
releaseByteBuf();

cleanup(true);
}

private void releaseByteBuf() {
if (current != null) {
current.release();
}

current = null;
buffer = null;
}

protected synchronized ByteBuffer awaitNext() {
Expand Down Expand Up @@ -137,6 +141,23 @@ protected void cleanup(boolean drain) {
}
}

@Override
public int available() throws IOException {
if (end || reading) {
return 0;
}
if (current != null) {
return current.readableBytes();
}
if (!isList.isEmpty()) {
final ByteBuf peek = isList.peek();
if (peek != null && peek.isReadable()) {
return peek.readableBytes();
}
}
return 0;
}

public synchronized void publish(ByteBuf content) {
if (end || content.nioBuffer().remaining() == 0) {
content.release();
Expand Down