1
0
Fork 0
forked from External/mediamtx

fix race condition

This commit is contained in:
aler9 2020-09-03 16:02:58 +02:00
parent dd151e9978
commit ca22fafdd7
2 changed files with 7 additions and 3 deletions

View file

@ -350,7 +350,7 @@ outer:
}()
for _, p := range p.paths {
p.onClose()
p.onClose(true)
}
p.serverRtsp.close()

View file

@ -78,7 +78,7 @@ func (pa *path) onInit() {
}
}
func (pa *path) onClose() {
func (pa *path) onClose(wait bool) {
if pa.source != nil {
close(pa.source.terminate)
<-pa.source.done
@ -104,6 +104,10 @@ func (pa *path) onClose() {
c.describe <- describeRes{nil, fmt.Errorf("publisher of path '%s' has timed out", pa.name)}
} else {
c.close()
if wait {
<- c.done
}
}
}
}
@ -175,7 +179,7 @@ func (pa *path) onCheck() {
if !pa.permanent &&
pa.publisher == nil &&
!pa.hasClients() {
pa.onClose()
pa.onClose(false)
delete(pa.p.paths, pa.name)
}
}