api: fix crash when changing settings of an on-demand source that is idle (#3246) (#3249)

This commit is contained in:
Alessandro Ros 2024-04-15 17:44:54 +02:00 committed by GitHub
parent 1c135fb62e
commit 95f1f79b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -371,7 +371,7 @@ func (pa *path) doReloadConf(newConf *conf.Path) {
pa.confMutex.Unlock()
if pa.conf.HasStaticSource() {
go pa.source.(*staticSourceHandler).reloadConf(newConf)
pa.source.(*staticSourceHandler).reloadConf(newConf)
}
if pa.conf.Record {

View File

@ -224,10 +224,18 @@ func (s *staticSourceHandler) run() {
}
func (s *staticSourceHandler) reloadConf(newConf *conf.Path) {
select {
case s.chReloadConf <- newConf:
case <-s.ctx.Done():
ctx := s.ctx
if !s.running {
return
}
go func() {
select {
case s.chReloadConf <- newConf:
case <-ctx.Done():
}
}()
}
// APISourceDescribe instanceements source.