Skip to content

Commit

Permalink
[usm] Fix concurrency issue in test (#15273)
Browse files Browse the repository at this point in the history
  • Loading branch information
p-lambert authored Jan 31, 2023
1 parent 74e462d commit 3cd6414
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/network/protocols/events/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"math"
"os"
"path/filepath"
"sync"
"testing"
"time"
"unsafe"
Expand Down Expand Up @@ -40,8 +41,11 @@ func TestConsumer(t *testing.T) {
program, err := newEBPFProgram(c)
require.NoError(t, err)

var mux sync.Mutex
result := make(map[uint64]int)
callback := func(b []byte) {
mux.Lock()
defer mux.Unlock()
// each event is just a uint64
n := binary.LittleEndian.Uint64(b)
result[n] = +1
Expand Down

0 comments on commit 3cd6414

Please sign in to comment.