Fix race condition when closing agent after gather

A data race would occur where the context cancel would
be called and overwritten at the same time.
This commit is contained in:
Kyle Carberry
2022-01-23 23:07:33 -05:00
committed by Sean DuBois
parent 208ef61810
commit 444e6c46fb
+1 -1
View File
@@ -893,10 +893,10 @@ func (a *Agent) Close() error {
done := make(chan struct{})
a.afterRun(func(context.Context) {
a.gatherCandidateCancel()
close(done)
})
a.gatherCandidateCancel()
a.err.Store(ErrClosed)
a.tcpMux.RemoveConnByUfrag(a.localUfrag)