Skip to content

Commit

Permalink
api: fix crash when changing settings of an on-demand source that is …
Browse files Browse the repository at this point in the history
…idle (#3246)
  • Loading branch information
aler9 committed Apr 15, 2024
1 parent 1c135fb commit ade077f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/core/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 374 in internal/core/path.go

View check run for this annotation

Codecov / codecov/patch

internal/core/path.go#L374

Added line #L374 was not covered by tests
}

if pa.conf.Record {
Expand Down
14 changes: 11 additions & 3 deletions internal/core/static_source_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 230 in internal/core/static_source_handler.go

View check run for this annotation

Codecov / codecov/patch

internal/core/static_source_handler.go#L227-L230

Added lines #L227 - L230 were not covered by tests
}

go func() {
select {
case s.chReloadConf <- newConf:
case <-ctx.Done():

Check warning on line 236 in internal/core/static_source_handler.go

View check run for this annotation

Codecov / codecov/patch

internal/core/static_source_handler.go#L233-L236

Added lines #L233 - L236 were not covered by tests
}
}()
}

// APISourceDescribe instanceements source.
Expand Down

0 comments on commit ade077f

Please sign in to comment.