Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public synchronized void close() throws IOException {
if (closed) {
return;
}

super.close();
writeBufferStartPosition.set(0);
Comment on lines +105 to +106
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we close and reset the position after setting the closed to true?


ReferenceCountUtil.release(writeBuffer);
fileChannel.close();
closed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.ReferenceCountUtil;
import java.io.IOException;
import java.nio.channels.FileChannel;

Expand All @@ -44,6 +45,8 @@ public class BufferedReadChannel extends BufferedChannelBase {
long invocationCount = 0;
long cacheHitCount = 0;

private boolean closed = false;

public BufferedReadChannel(FileChannel fileChannel, int readCapacity) {
super(fileChannel);
this.readCapacity = readCapacity;
Expand Down Expand Up @@ -103,4 +106,17 @@ public synchronized void clear() {
readBuffer.clear();
}

public synchronized void close() throws IOException {
if (closed) {
return;
}

readBufferStartPosition = Long.MIN_VALUE;
ReferenceCountUtil.release(readBuffer);

// BufferedReadChannel is not response for fileChannel close.

closed = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the closed to the first step?

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ private BufferedReadChannel getChannelForLogId(long entryLogId) throws IOExcepti
// We set the position of the write buffer of this buffered channel to Long.MAX_VALUE
// so that there are no overlaps with the write buffer while reading
fc = new BufferedReadChannel(newFc, conf.getReadBufferBytes());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

putInReadChannels(entryLogId, fc);
return fc;
}
Expand Down