RTSP source: apply TCP timeout correctly (#335)

This commit is contained in:
aler9 2021-04-04 19:45:41 +02:00
parent 90bc09c93c
commit f208026338
4 changed files with 21 additions and 25 deletions

2
go.mod
View file

@ -5,7 +5,7 @@ go 1.15
require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/aler9/gortsplib v0.0.0-20210404101813-cbb47e158ab2
github.com/aler9/gortsplib v0.0.0-20210404174403-c2d5ced43bcf
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51

4
go.sum
View file

@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/gortsplib v0.0.0-20210404101813-cbb47e158ab2 h1:4g4xmGdxEEGmfbTjwW13WiJ/9p2QS4fQVpHtyZJBkEY=
github.com/aler9/gortsplib v0.0.0-20210404101813-cbb47e158ab2/go.mod h1:zVCg+TQX445hh1pC5QgAuuBvvXZMWLY1XYz626dGFqY=
github.com/aler9/gortsplib v0.0.0-20210404174403-c2d5ced43bcf h1:X8ToQ1H9I7gLp37fxH7mo/U0y+GgF+kwmHpeht4MUHE=
github.com/aler9/gortsplib v0.0.0-20210404174403-c2d5ced43bcf/go.mod h1:zVCg+TQX445hh1pC5QgAuuBvvXZMWLY1XYz626dGFqY=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=

View file

@ -258,17 +258,15 @@ func (s *Source) runInner() bool {
}()
}()
for {
select {
case err := <-readerDone:
conn.NetConn().Close()
s.log(logger.Info, "ERR: %s", err)
return true
select {
case <-s.terminate:
conn.NetConn().Close()
<-readerDone
return false
case <-s.terminate:
conn.NetConn().Close()
<-readerDone
return false
}
case err := <-readerDone:
s.log(logger.Info, "ERR: %s", err)
conn.NetConn().Close()
return true
}
}

View file

@ -168,17 +168,15 @@ func (s *Source) runInner() bool {
res.SP.OnFrame(trackID, streamType, payload)
})
for {
select {
case <-s.terminate:
conn.Close()
<-done
return false
select {
case <-s.terminate:
conn.Close()
<-done
return false
case err := <-done:
conn.Close()
s.log(logger.Info, "ERR: %s", err)
return true
}
case err := <-done:
s.log(logger.Info, "ERR: %s", err)
conn.Close()
return true
}
}