Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion ringbuf/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestRingbufReader(t *testing.T) {
}
defer rd.Close()

if uint32(rd.BufferSize()) != 2*events.MaxEntries() {
if uint32(rd.BufferSize()) != events.MaxEntries() {
t.Errorf("expected %d BufferSize, got %d", events.MaxEntries(), rd.BufferSize())
}

Expand Down
4 changes: 3 additions & 1 deletion ringbuf/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ func (rr *ringReader) isEmpty() bool {
return prod == cons
}

// The data pages in ring buffers are mapped twice in a single contiguous virtual region
// Therefore the true size is half the size of the mmaped region
func (rr *ringReader) size() int {
return cap(rr.ring)
return cap(rr.ring) / 2
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to fix TestRingbufReader to accommodate this change.

}

// Read a record from an event ring.
Expand Down