fix deadlock when sourceOnDemand is true and source exits
This commit is contained in:
parent
8c2b12a314
commit
f5a031d72c
|
@ -460,12 +460,14 @@ func (pa *path) run() {
|
||||||
case req := <-pa.chSourceStaticSetNotReady:
|
case req := <-pa.chSourceStaticSetNotReady:
|
||||||
pa.sourceSetNotReady()
|
pa.sourceSetNotReady()
|
||||||
|
|
||||||
|
// send response before calling onDemandStaticSourceStop()
|
||||||
|
// in order to avoid a deadlock due to sourceStatic.stop()
|
||||||
|
close(req.res)
|
||||||
|
|
||||||
if pa.hasOnDemandStaticSource() && pa.onDemandStaticSourceState != pathOnDemandStateInitial {
|
if pa.hasOnDemandStaticSource() && pa.onDemandStaticSourceState != pathOnDemandStateInitial {
|
||||||
pa.onDemandStaticSourceStop()
|
pa.onDemandStaticSourceStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
close(req.res)
|
|
||||||
|
|
||||||
if pa.shouldClose() {
|
if pa.shouldClose() {
|
||||||
return fmt.Errorf("not in use")
|
return fmt.Errorf("not in use")
|
||||||
}
|
}
|
||||||
|
@ -975,7 +977,7 @@ func (pa *path) sourceStaticSetReady(sourceStaticCtx context.Context, req pathSo
|
||||||
|
|
||||||
// this avoids:
|
// this avoids:
|
||||||
// - invalid requests sent after the source has been terminated
|
// - invalid requests sent after the source has been terminated
|
||||||
// - freezes caused by <-done inside stop()
|
// - deadlocks caused by <-done inside stop()
|
||||||
case <-sourceStaticCtx.Done():
|
case <-sourceStaticCtx.Done():
|
||||||
req.res <- pathSourceStaticSetReadyRes{err: fmt.Errorf("terminated")}
|
req.res <- pathSourceStaticSetReadyRes{err: fmt.Errorf("terminated")}
|
||||||
}
|
}
|
||||||
|
@ -991,7 +993,7 @@ func (pa *path) sourceStaticSetNotReady(sourceStaticCtx context.Context, req pat
|
||||||
|
|
||||||
// this avoids:
|
// this avoids:
|
||||||
// - invalid requests sent after the source has been terminated
|
// - invalid requests sent after the source has been terminated
|
||||||
// - freezes caused by <-done inside stop()
|
// - deadlocks caused by <-done inside stop()
|
||||||
case <-sourceStaticCtx.Done():
|
case <-sourceStaticCtx.Done():
|
||||||
close(req.res)
|
close(req.res)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue