Skip to content

Commit e6f7479

Browse files
committed
Simplify mutex usage
Signed-off-by: Šimon Brandner <[email protected]>
1 parent e36fa26 commit e6f7479

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/call.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,15 @@ func (c *Call) onDCUnpublish(stop []event.SFUTrackDescription, sdp string) {
136136

137137
newPublishers := []*Publisher{}
138138

139-
c.mutex.RLock()
139+
c.mutex.Lock()
140140
for _, publisher := range c.Publishers {
141141
if publisher.Matches(trackDesc) {
142142
publisher.Stop()
143143
} else {
144144
newPublishers = append(newPublishers, publisher)
145145
}
146146
}
147-
c.mutex.RUnlock()
148147

149-
c.mutex.Lock()
150148
c.Publishers = newPublishers
151149
c.mutex.Unlock()
152150
}
@@ -550,15 +548,13 @@ func (c *Call) CheckKeepAliveTimestamp() {
550548
func (c *Call) RemoveSubscriber(toDelete *Subscriber) {
551549
newSubscribers := []*Subscriber{}
552550

553-
c.mutex.RLock()
551+
c.mutex.Lock()
554552
for _, subscriber := range c.Subscribers {
555553
if subscriber != toDelete {
556554
newSubscribers = append(newSubscribers, subscriber)
557555
}
558556
}
559-
c.mutex.RUnlock()
560557

561-
c.mutex.Lock()
562558
c.Subscribers = newSubscribers
563559
c.mutex.Unlock()
564560
}

0 commit comments

Comments
 (0)