Skip to content

Commit a9d5266

Browse files
committed
Re-adds syncchronization, needed for the finalizer
1 parent d975368 commit a9d5266

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

comp/dogstatsd/server/intern.go

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package server
77

88
import (
99
"runtime"
10+
"sync"
1011
"unsafe"
1112

1213
"github.com/DataDog/datadog-agent/pkg/config/utils"
@@ -41,6 +42,7 @@ func (v *StringValue) Get() string {
4142
// stringInterner interns strings while allowing them to be cleaned up by the GC.
4243
// It can handle both string and []byte types without allocation.
4344
type stringInterner struct {
45+
mu sync.Mutex
4446
tlmEnabled bool
4547
valMap map[string]uintptr
4648
}
@@ -66,6 +68,9 @@ func newStringInterner() *stringInterner {
6668
//
6769
//go:nocheckptr
6870
func (s *stringInterner) LoadOrStore(k []byte) *StringValue {
71+
s.mu.Lock()
72+
defer s.mu.Unlock()
73+
6974
var v *StringValue
7075
// the compiler will optimize the following map lookup to not alloc a string
7176
if addr, ok := s.valMap[string(k)]; ok {
@@ -86,6 +91,8 @@ func (s *stringInterner) LoadOrStore(k []byte) *StringValue {
8691
}
8792

8893
func (s *stringInterner) finalize(v *StringValue) {
94+
s.mu.Lock()
95+
defer s.mu.Unlock()
8996
if v.resurrected {
9097
// We lost the race. Somebody resurrected it while we
9198
// were about to finalize it. Try again next round.

0 commit comments

Comments
 (0)