diff options
author | zeripath <art27@cantab.net> | 2020-02-01 23:43:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-01 23:43:50 +0000 |
commit | 9b9dd19d7dfe826789f0690f84d9f59470ad9e82 (patch) | |
tree | de94fa2f996edaa806c39e488892f0ae2663cf17 /modules/queue | |
parent | 72f9cfc8f05e744befca63b9cc2a1b10c009621d (diff) | |
download | gitea-9b9dd19d7dfe826789f0690f84d9f59470ad9e82.tar.gz gitea-9b9dd19d7dfe826789f0690f84d9f59470ad9e82.zip |
Fix broken FlushAll (#10101)
* go function contexting is not what you expect
* Apply suggestions from code review
Co-Authored-By: Lauris BH <lauris@nix.lv>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/queue')
-rw-r--r-- | modules/queue/manager.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/queue/manager.go b/modules/queue/manager.go index a6734787a9..3e9f8fc8db 100644 --- a/modules/queue/manager.go +++ b/modules/queue/manager.go @@ -183,17 +183,17 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error } allEmpty = false if flushable, ok := mq.Managed.(Flushable); ok { - go func() { + go func(q *ManagedQueue) { localCtx, localCancel := context.WithCancel(ctx) - pid := mq.RegisterWorkers(1, start, hasTimeout, end, localCancel, true) + pid := q.RegisterWorkers(1, start, hasTimeout, end, localCancel, true) err := flushable.FlushWithContext(localCtx) if err != nil && err != ctx.Err() { cancel() } - mq.CancelWorkers(pid) + q.CancelWorkers(pid) localCancel() wg.Done() - }() + }(mq) } else { wg.Done() } |