Skip to content

Commit

Permalink
fix freeze when getting metrics and a RTSP connection is being created (
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Feb 2, 2025
1 parent a1c6da8 commit 1a1da5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/servers/rtsp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (

type connParent interface {
logger.Writer
findSessionByRSession(rsession *gortsplib.ServerSession) *session
findSessionByRSessionUnsafe(rsession *gortsplib.ServerSession) *session
}

type conn struct {
Expand Down Expand Up @@ -222,7 +222,7 @@ func (c *conn) apiItem() *defs.APIRTSPConn {
BytesReceived: stats.BytesReceived,
BytesSent: stats.BytesSent,
Session: func() *uuid.UUID {
sx := c.parent.findSessionByRSession(c.rconn.Session())
sx := c.parent.findSessionByRSessionUnsafe(c.rconn.Session())
if sx != nil {
return &sx.uuid
}
Expand Down
5 changes: 1 addition & 4 deletions internal/servers/rtsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,7 @@ func (s *Server) findSessionByUUID(uuid uuid.UUID) (*gortsplib.ServerSession, *s
return nil, nil
}

func (s *Server) findSessionByRSession(rsession *gortsplib.ServerSession) *session {
s.mutex.RLock()
defer s.mutex.RUnlock()

func (s *Server) findSessionByRSessionUnsafe(rsession *gortsplib.ServerSession) *session {
return s.sessions[rsession]
}

Expand Down

0 comments on commit 1a1da5e

Please sign in to comment.