Skip to content

Commit

Permalink
fix(templating): data race in array append
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Sep 4, 2024
1 parent 825acca commit f130b9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/templating/templating.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ var funcMap = template.FuncMap{

// UniqueProtocolName takes a protocol-safe string and address family and returns a unique protocol name
"UniqueProtocolName": func(s, userSuppliedName *string, af string, asn *int, tags *[]string) string {
protocolNameMapLock.Lock()
defer protocolNameMapLock.Unlock()

protoName := fmt.Sprintf("%s_AS%d_v%s", *s, *asn, af)
i := 1
for {
Expand All @@ -201,12 +204,10 @@ var funcMap = template.FuncMap{
if tags != nil {
t = *tags
}
protocolNameMapLock.Lock()
protocolNameMap[protoName] = &Protocol{
Name: *userSuppliedName,
Tags: t,
}
protocolNameMapLock.Unlock()
return protoName
}
protoName = fmt.Sprintf("%s_AS%d_v%s_%d", *s, *asn, af, i)
Expand Down

0 comments on commit f130b9a

Please sign in to comment.