Allow multiple agent.Close

This commit is contained in:
Eric Daniels
2024-08-05 21:59:05 -04:00
committed by Sean DuBois
parent 63ede543de
commit 28cf1cd9f3
2 changed files with 4 additions and 6 deletions
+2 -2
View File
@@ -861,14 +861,14 @@ func (a *Agent) GracefulClose() error {
func (a *Agent) close(graceful bool) error {
// the loop is safe to wait on no matter what
err := a.loop.Close()
a.loop.Close()
// but we are in less control of the notifiers, so we will
// pass through `graceful`.
a.connectionStateNotifier.Close(graceful)
a.candidateNotifier.Close(graceful)
a.selectedCandidatePairNotifier.Close(graceful)
return err
return nil
}
// Remove all candidates. This closes any listening sockets
+2 -4
View File
@@ -63,17 +63,15 @@ func (l *Loop) runLoop(onClose func()) {
// Close stops the loop after finishing the execution of the current task.
// Other pending tasks will not be executed.
func (l *Loop) Close() error {
func (l *Loop) Close() {
if err := l.Err(); err != nil {
return err
return
}
l.err.Store(ErrClosed)
close(l.done)
<-l.taskLoopDone
return nil
}
// Run serially executes the submitted callback.