Skip to content

Commit

Permalink
Allow multiple agent.Close
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniels committed Aug 6, 2024
1 parent dd25059 commit 1f41061
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package ice

import (
"context"
"errors"
"fmt"
"math"
"net"
Expand Down Expand Up @@ -927,6 +928,9 @@ func (a *Agent) GracefulClose() error {

func (a *Agent) close(graceful bool) error {
if err := a.ok(); err != nil {
if errors.Is(err, ErrClosed) {
return nil
}
return err
}

Expand Down
5 changes: 2 additions & 3 deletions agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,6 @@ func TestAgentGracefulCloseDeadlock(t *testing.T) {
closeNow.Done()
closed.Wait()

// already closed
require.Error(t, aAgent.Close())
require.Error(t, bAgent.Close())
require.NoError(t, aAgent.Close())
require.NoError(t, bAgent.Close())
}

0 comments on commit 1f41061

Please sign in to comment.