Merge pull request #327 from strukturag/fix-proxy-deadlock

Fix deadlock for proxy connection issues
This commit is contained in:
Joachim Bauch 2022-08-30 15:45:31 +02:00 committed by GitHub
commit 1774d56d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

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
}

View file

@ -488,7 +488,7 @@ func (c *mcuProxyConnection) sendPing() bool {
c.conn.SetWriteDeadline(now.Add(writeWait)) // nolint
if err := c.conn.WriteMessage(websocket.PingMessage, []byte(msg)); err != nil {
log.Printf("Could not send ping to proxy at %s: %v", c, err)
c.scheduleReconnect()
go c.scheduleReconnect()
return false
}
@ -1042,6 +1042,8 @@ func (c *mcuProxyConnection) newPublisher(ctx context.Context, listener McuListe
if err != nil {
// TODO: Cancel request
return nil, err
} else if response.Type == "error" {
return nil, fmt.Errorf("Error creating %s publisher for %s on %s: %+v", streamType, id, c, response.Error)
}
proxyId := response.Command.Id
@ -1070,6 +1072,8 @@ func (c *mcuProxyConnection) newSubscriber(ctx context.Context, listener McuList
if err != nil {
// TODO: Cancel request
return nil, err
} else if response.Type == "error" {
return nil, fmt.Errorf("Error creating %s subscriber for %s on %s: %+v", streamType, publisherSessionId, c, response.Error)
}
proxyId := response.Command.Id