fix 'runOnDemandRestart: yes' (#1947)

This commit is contained in:
Alessandro Ros 2023-06-21 13:25:26 +02:00 committed by GitHub
parent fe5b09b28e
commit d3354a0c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -606,19 +606,18 @@ func (pa *path) onDemandPublisherScheduleClose() {
}
func (pa *path) onDemandPublisherStop() {
if pa.source != nil {
pa.source.(publisher).close()
pa.doPublisherRemove()
}
if pa.onDemandPublisherState == pathOnDemandStateClosing {
pa.onDemandPublisherCloseTimer.Stop()
pa.onDemandPublisherCloseTimer = newEmptyTimer()
}
// set state before doPublisherRemove()
pa.onDemandPublisherState = pathOnDemandStateInitial
if pa.source != nil {
pa.source.(publisher).close()
pa.doPublisherRemove()
}
if pa.onDemandCmd != nil {
pa.onDemandCmd.Close()
pa.onDemandCmd = nil
@ -683,11 +682,7 @@ func (pa *path) doReaderRemove(r reader) {
func (pa *path) doPublisherRemove() {
if pa.stream != nil {
if pa.conf.HasOnDemandPublisher() && pa.onDemandPublisherState != pathOnDemandStateInitial {
pa.onDemandPublisherStop()
} else {
pa.sourceSetNotReady()
}
pa.sourceSetNotReady()
}
pa.source = nil
@ -811,11 +806,7 @@ func (pa *path) handlePublisherStart(req pathPublisherStartReq) {
func (pa *path) handlePublisherStop(req pathPublisherStopReq) {
if req.author == pa.source && pa.stream != nil {
if pa.conf.HasOnDemandPublisher() && pa.onDemandPublisherState != pathOnDemandStateInitial {
pa.onDemandPublisherStop()
} else {
pa.sourceSetNotReady()
}
pa.sourceSetNotReady()
}
close(req.res)
}