avoid deadlock when a runOnPublish command is reading and the publisher times out (#595) (#495)

This commit is contained in:
aler9 2021-10-03 15:58:24 +02:00
parent 160966e81b
commit d2c668ceea

View File

@ -564,17 +564,22 @@ func (pa *path) sourceSetReady(tracks gortsplib.Tracks) {
}
func (pa *path) sourceSetNotReady() {
for r := range pa.readers {
pa.doReaderRemove(r)
r.Close()
}
// close onPublishCmd after all readers have been closed.
// this avoids a deadlock in which onPublishCmd is a
// RTSP reader that sends a TEARDOWN request and waits
// for the response (like FFmpeg), but it can't since
/// the path is already waiting for the command to close.
if pa.onPublishCmd != nil {
pa.onPublishCmd.Close()
pa.onPublishCmd = nil
pa.Log(logger.Info, "runOnPublish command stopped")
}
for r := range pa.readers {
pa.doReaderRemove(r)
r.Close()
}
pa.sourceReady = false
pa.stream.close()
pa.stream = nil