Take Track write Lock in NewRTPSender

Track is locking for reading when actually writing
is taking place
This commit is contained in:
cyannuk
2019-12-29 01:07:07 +06:00
committed by Sean DuBois
parent 974d2e2b5f
commit 14fa0b54ef
2 changed files with 3 additions and 2 deletions

View File

@@ -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

View File

@@ -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")
}