Skip to content

Commit 323bcf9

Browse files
committed
Lock on TL register
1 parent 61d152f commit 323bcf9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tl/loader.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"hash/crc32"
1010
"reflect"
1111
"strings"
12+
"sync"
1213
)
1314

1415
type Serializable interface{}
@@ -126,7 +127,12 @@ func Register(typ any, tl string) uint32 {
126127
})
127128
}
128129

130+
var initMx sync.Mutex
131+
129132
func RegisterWithFabric(typ any, tl string, fab func() reflect.Value) uint32 {
133+
initMx.Lock() // we lock because init() methods in independent packages can be called in parallel
134+
defer initMx.Unlock()
135+
130136
t := reflect.TypeOf(typ)
131137

132138
si := getStructInfoReference(t)

0 commit comments

Comments
 (0)