mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-09-11 17:31:08 +02:00
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>
This commit is contained in:
parent
72f9cfc8f0
commit
9b9dd19d7d
|
@ -183,17 +183,17 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error
|
||||||
}
|
}
|
||||||
allEmpty = false
|
allEmpty = false
|
||||||
if flushable, ok := mq.Managed.(Flushable); ok {
|
if flushable, ok := mq.Managed.(Flushable); ok {
|
||||||
go func() {
|
go func(q *ManagedQueue) {
|
||||||
localCtx, localCancel := context.WithCancel(ctx)
|
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)
|
err := flushable.FlushWithContext(localCtx)
|
||||||
if err != nil && err != ctx.Err() {
|
if err != nil && err != ctx.Err() {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
mq.CancelWorkers(pid)
|
q.CancelWorkers(pid)
|
||||||
localCancel()
|
localCancel()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}(mq)
|
||||||
} else {
|
} else {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue