fixed panic when client connected abruptly

This commit is contained in:
David Zhao
2021-01-26 17:38:47 -08:00
parent b96028b4d6
commit a065a01592
10 changed files with 54 additions and 10 deletions
+5 -1
View File
@@ -320,7 +320,6 @@ func (p *ParticipantImpl) Close() error {
if p.ctx.Err() != nil {
return p.ctx.Err()
}
close(p.rtcpCh)
p.onICECandidate = nil
p.peerConn.OnDataChannel(nil)
p.peerConn.OnICECandidate(nil)
@@ -332,6 +331,7 @@ func (p *ParticipantImpl) Close() error {
p.onClose(p)
}
p.cancel()
close(p.rtcpCh)
return p.peerConn.Close()
}
@@ -434,6 +434,10 @@ func (p *ParticipantImpl) scheduleNegotiate() {
// initiates server-driven negotiation by creating an offer
func (p *ParticipantImpl) negotiate() {
if p.state == livekit.ParticipantInfo_DISCONNECTED {
// skip when disconnected
return
}
p.negotiationCond.L.Lock()
for p.negotiationState != negotiationStateNone {
p.negotiationCond.Wait()