Skip to content

Commit

Permalink
pkg/ebpf: remove pointer from DataEvent usage (DataDog#28663)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux authored Aug 28, 2024
1 parent dc8af2c commit fb92620
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/ebpf/perf.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ EventHandler = new(PerfHandler)
type PerfHandler struct {
RecordGetter func() *perf.Record

dataChannel chan *DataEvent
dataChannel chan DataEvent
lostChannel chan uint64
once sync.Once
closed bool
Expand All @@ -39,7 +39,7 @@ func NewPerfHandler(dataChannelSize int) *PerfHandler {
RecordGetter: func() *perf.Record {
return recordPool.Get()
},
dataChannel: make(chan *DataEvent, dataChannelSize),
dataChannel: make(chan DataEvent, dataChannelSize),
lostChannel: make(chan uint64, 10),
}
}
Expand All @@ -58,11 +58,11 @@ func (c *PerfHandler) RecordHandler(record *perf.Record, _ *manager.PerfMap, _ *
return
}

c.dataChannel <- &DataEvent{Data: record.RawSample, pr: record}
c.dataChannel <- DataEvent{Data: record.RawSample, pr: record}
}

// DataChannel returns the channel with event data
func (c *PerfHandler) DataChannel() <-chan *DataEvent {
func (c *PerfHandler) DataChannel() <-chan DataEvent {
return c.dataChannel
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/perf_data_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// EventHandler is the common interface shared across perf map and perf ring
// buffer handlers
type EventHandler interface {
DataChannel() <-chan *DataEvent
DataChannel() <-chan DataEvent
LostChannel() <-chan uint64
Stop()
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/ebpf/perf_ring_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ EventHandler = new(RingBufferHandler)
type RingBufferHandler struct {
RecordGetter func() *ringbuf.Record

dataChannel chan *DataEvent
dataChannel chan DataEvent
lostChannel chan uint64
once sync.Once
closed bool
Expand All @@ -39,7 +39,7 @@ func NewRingBufferHandler(dataChannelSize int) *RingBufferHandler {
RecordGetter: func() *ringbuf.Record {
return ringPool.Get()
},
dataChannel: make(chan *DataEvent, dataChannelSize),
dataChannel: make(chan DataEvent, dataChannelSize),
// This channel is not really used in the context of ring buffers but
// it's here so `RingBufferHandler` and `PerfHandler` can be used
// interchangeably
Expand All @@ -53,11 +53,11 @@ func (c *RingBufferHandler) RecordHandler(record *ringbuf.Record, _ *manager.Rin
return
}

c.dataChannel <- &DataEvent{Data: record.RawSample, rr: record}
c.dataChannel <- DataEvent{Data: record.RawSample, rr: record}
}

// DataChannel returns the channel with event data
func (c *RingBufferHandler) DataChannel() <-chan *DataEvent {
func (c *RingBufferHandler) DataChannel() <-chan DataEvent {
return c.dataChannel
}

Expand Down

0 comments on commit fb92620

Please sign in to comment.