File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package server
7
7
8
8
import (
9
9
"runtime"
10
+ "sync"
10
11
"unsafe"
11
12
12
13
"github.com/DataDog/datadog-agent/pkg/config/utils"
@@ -41,6 +42,7 @@ func (v *StringValue) Get() string {
41
42
// stringInterner interns strings while allowing them to be cleaned up by the GC.
42
43
// It can handle both string and []byte types without allocation.
43
44
type stringInterner struct {
45
+ mu sync.Mutex
44
46
tlmEnabled bool
45
47
valMap map [string ]uintptr
46
48
}
@@ -66,6 +68,9 @@ func newStringInterner() *stringInterner {
66
68
//
67
69
//go:nocheckptr
68
70
func (s * stringInterner ) LoadOrStore (k []byte ) * StringValue {
71
+ s .mu .Lock ()
72
+ defer s .mu .Unlock ()
73
+
69
74
var v * StringValue
70
75
// the compiler will optimize the following map lookup to not alloc a string
71
76
if addr , ok := s .valMap [string (k )]; ok {
@@ -86,6 +91,8 @@ func (s *stringInterner) LoadOrStore(k []byte) *StringValue {
86
91
}
87
92
88
93
func (s * stringInterner ) finalize (v * StringValue ) {
94
+ s .mu .Lock ()
95
+ defer s .mu .Unlock ()
89
96
if v .resurrected {
90
97
// We lost the race. Somebody resurrected it while we
91
98
// were about to finalize it. Try again next round.
You can’t perform that action at this time.
0 commit comments