Use "defer" to re-acquire released lock.

This commit is contained in:
Joachim Bauch 2022-08-30 11:47:38 +02:00
parent cdbc177179
commit 960cb0ea3c
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -839,6 +839,7 @@ func (s *ClientSession) GetOrCreatePublisher(ctx context.Context, mcu Mcu, strea
if !found {
client := s.getClientUnlocked()
s.mu.Unlock()
defer s.mu.Lock()
bitrate := data.Bitrate
if backend := s.Backend(); backend != nil {
@ -856,7 +857,6 @@ func (s *ClientSession) GetOrCreatePublisher(ctx context.Context, mcu Mcu, strea
}
var err error
publisher, err = mcu.NewPublisher(ctx, s, s.PublicId(), data.Sid, streamType, bitrate, mediaTypes, client)
s.mu.Lock()
if err != nil {
return nil, err
}