From 71ac5557aba51f33db24b5316c9e6b8e439f1393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sidney=20San=20Marti=CC=81n?= Date: Sat, 15 Aug 2020 18:41:22 -0400 Subject: [PATCH] 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. --- README.md | 1 + agent.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e76e5c..7ef6f52 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/agent.go b/agent.go index 26ed93f..1bbe966 100644 --- a/agent.go +++ b/agent.go @@ -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