Skip to content

Commit

Permalink
Merge pull request #17 from libp2p/fix/issue-16
Browse files Browse the repository at this point in the history
Pacify the race detector
  • Loading branch information
vyzo authored Mar 5, 2019
2 parents fb9be13 + 5ab68af commit 6d26667
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions p2p/host/autonat/autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func NewAutoNAT(ctx context.Context, h host.Host, getAddrs GetAddrs) AutoNAT {
}

func (as *AmbientAutoNAT) Status() NATStatus {
as.mx.Lock()
defer as.mx.Unlock()
return as.status
}

Expand Down
3 changes: 2 additions & 1 deletion p2p/host/autonat/autonat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ func newDialResponseError(status pb.Message_ResponseStatus, text string) *pb.Mes
func makeAutoNAT(ctx context.Context, t *testing.T, ash host.Host) (host.Host, AutoNAT) {
h := bhost.NewBlankHost(swarmt.GenSwarm(t, ctx))
a := NewAutoNAT(ctx, h, nil)
a.(*AmbientAutoNAT).mx.Lock()
a.(*AmbientAutoNAT).peers[ash.ID()] = ash.Addrs()

a.(*AmbientAutoNAT).mx.Unlock()
return h, a
}

Expand Down

0 comments on commit 6d26667

Please sign in to comment.