fix: too many open files caused by agent not being closed (#154)

* fix: too many open files caused by agent not being closed after unsuccessful attempts to start a peer connection (happens when no network available)

* fix: minor refactor to consider signal status
This commit is contained in:
Mikhail Bragin
2021-11-14 19:41:17 +01:00
committed by GitHub
parent 95ef8547f3
commit d08e5efbce
4 changed files with 29 additions and 14 deletions
+8 -2
View File
@@ -138,12 +138,18 @@ func (conn *Connection) Open(timeout time.Duration) error {
return !ok
},
})
conn.agent = a
if err != nil {
return err
}
conn.agent = a
defer func() {
err := conn.agent.Close()
if err != nil {
return
}
}()
err = conn.listenOnLocalCandidates()
if err != nil {
return err