Skip to content
Merged
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
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
5 changes: 4 additions & 1 deletion ringbuf/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ func (rr *ringReader) isEmpty() bool {
return prod == cons
}

// To be able to wrap around data, data pages in ring buffers are mapped twice in
// a single contiguous virtual region.
// Therefore the returned usable 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