File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -142,14 +142,22 @@ type Conn struct {
142
142
func (c * Conn ) init () error {
143
143
c .rtc .OnNegotiationNeeded (c .negotiate )
144
144
c .rtc .OnICEConnectionStateChange (func (iceConnectionState webrtc.ICEConnectionState ) {
145
+ // Close must be locked here otherwise log output can appear
146
+ // after the connection has been closed.
147
+ c .closeMutex .Lock ()
148
+ defer c .closeMutex .Unlock ()
145
149
if c .isClosed () {
146
150
return
147
151
}
148
152
149
- c .opts .Logger .Debug (context .Background (), "ice connection updated" ,
153
+ c .opts .Logger .Debug (context .Background (), "ice connection state updated" ,
150
154
slog .F ("state" , iceConnectionState ))
151
155
})
152
156
c .rtc .OnICEGatheringStateChange (func (iceGatherState webrtc.ICEGathererState ) {
157
+ // Close can't be locked here, because this is triggered
158
+ // when close is called. It doesn't appear this get's
159
+ // executed after close though, so it shouldn't cause
160
+ // problems.
153
161
if c .isClosed () {
154
162
return
155
163
}
You can’t perform that action at this time.
0 commit comments