Don't leak goroutines via mDNS queries

mDNSConn.Query() will block indefinitely until something replies. Much
of the time, nothing will, and the goroutines making these queries will
block forever. By passing the CandidateHost's context, the queries will
at least be cancelled when the host disconnects.
This commit is contained in:
Sidney San Martín
2020-08-15 21:55:22 -07:00
committed by Sean DuBois
parent b828116017
commit 71ac5557ab
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -55,6 +55,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [BUPTCZQ](https://github.com/buptczq)
* [Henry](https://github.com/cryptix)
* [Jerko Steiner](https://github.com/jeremija)
* [Sidney San Martín](https://github.com/s4y)
### License
MIT License - see [LICENSE](LICENSE) for full text
+1 -1
View File
@@ -741,7 +741,7 @@ func (a *Agent) resolveAndAddMulticastCandidate(c *CandidateHost) {
if a.mDNSConn == nil {
return
}
_, src, err := a.mDNSConn.Query(context.TODO(), c.Address())
_, src, err := a.mDNSConn.Query(c.context(), c.Address())
if err != nil {
a.log.Warnf("Failed to discover mDNS candidate %s: %v", c.Address(), err)
return