Skip to content

Commit

Permalink
cshared: Make goroutine for Collect to be able to exit
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Oct 6, 2023
1 parent 589518f commit 5bd8020
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,16 @@ func prepareInputCollector() (err error) {

go func(theChannel chan<- Message) {
defer theInputLock.Unlock()
for {
select {
case <-runCtx.Done():
log.Printf("goroutine will be stopping: name=%q\n", theName)
return
default:
err = theInput.Collect(runCtx, theChannel)
}
}

err := theInput.Collect(runCtx, theChannel)
if err != nil {
fmt.Fprintf(os.Stderr,
"collect error: %s\n", err.Error())
Expand Down

0 comments on commit 5bd8020

Please sign in to comment.