Skip to content

Commit

Permalink
signalflow client: Handle receipt of duplicate info messages without …
Browse files Browse the repository at this point in the history
…crashing (#206)

Certain types of jobs can cause the resolution info message to be sent twice
for some reason, causing a panic on the close channel for the asyncMetadata.Set
call
  • Loading branch information
benkeith-splunk authored Nov 7, 2023
1 parent 46bfc1b commit f201bf2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions signalflow/computation.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ var ErrMetadataTimeout = errors.New("metadata value did not come in time")

type asyncMetadata[T any] struct {
sync.Mutex
sig chan struct{}
val T
sig chan struct{}
isSet bool
val T
}

func (a *asyncMetadata[T]) ensureInit() {
Expand All @@ -349,7 +350,10 @@ func (a *asyncMetadata[T]) Set(val T) {
a.ensureInit()
a.Lock()
a.val = val
close(a.sig)
if !a.isSet {
close(a.sig)
a.isSet = true
}
a.Unlock()
}

Expand Down

0 comments on commit f201bf2

Please sign in to comment.