From 14fa0b54ef6db119a16f9ab6da99ba544cf1ec62 Mon Sep 17 00:00:00 2001 From: cyannuk Date: Sun, 29 Dec 2019 01:07:07 +0600 Subject: [PATCH] Take Track write Lock in NewRTPSender Track is locking for reading when actually writing is taking place --- README.md | 1 + rtpsender.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e41347c3..a203a8c5 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu * [David Hamilton](https://github.com/dihamilton) * [Ilya Mayorov](https://github.com/faroyam) * [Patrick Lange](https://github.com/langep) +* [cyannuk](https://github.com/cyannuk) ### License MIT License - see [LICENSE](LICENSE) for full text diff --git a/rtpsender.go b/rtpsender.go index 3e3f2737..188b1a30 100644 --- a/rtpsender.go +++ b/rtpsender.go @@ -33,8 +33,8 @@ func (api *API) NewRTPSender(track *Track, transport *DTLSTransport) (*RTPSender return nil, fmt.Errorf("DTLSTransport must not be nil") } - track.mu.RLock() - defer track.mu.RUnlock() + track.mu.Lock() + defer track.mu.Unlock() if track.receiver != nil { return nil, fmt.Errorf("RTPSender can not be constructed with remote track") }