Skip to content

Commit

Permalink
close chan on jobrun goroutine instead
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Nov 18, 2024
1 parent 27516d8 commit a40bff6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/backend/backup/jobrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ func RunBackup(job *store.Job, storeInstance *store.Store, waitChan chan struct{
var task *store.Task
go func() {
taskC := <-taskChan
log.Printf("Task received: %s\n", taskC.UPID)
task = &taskC

close(taskChan)
}()

for {
Expand Down
1 change: 0 additions & 1 deletion internal/store/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (storeInstance *Store) GetMostRecentTask(ctx context.Context, job *Job) (ch

go func() {
defer watcher.Close()
defer close(returnChan)
for {
select {
case event := <-watcher.Events:
Expand Down

0 comments on commit a40bff6

Please sign in to comment.