Skip to content

Commit

Permalink
Fix race in nat traversal (ava-labs#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-kim authored Nov 25, 2022
1 parent 1437bfe commit b450f46
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (m *Mapper) Map(protocol string, intPort, extPort uint16, desc string, ip i
)
}

m.wg.Add(1)
go m.keepPortMapping(protocol, intPort, extPort, desc, ip, updateTime)
}

Expand Down Expand Up @@ -112,8 +113,6 @@ func (m *Mapper) retryMapPort(protocol string, intPort, extPort uint16, desc str
func (m *Mapper) keepPortMapping(protocol string, intPort, extPort uint16, desc string, ip ips.DynamicIPPort, updateTime time.Duration) {
updateTimer := time.NewTimer(updateTime)

m.wg.Add(1)

defer func(extPort uint16) {
updateTimer.Stop()

Expand Down

0 comments on commit b450f46

Please sign in to comment.