Commit 7bbd6177 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Levin Zimmermann

wcfs: Fix readPinWatchers error path

Inside readPinWatchers:

    https://lab.nexedi.com/nexedi/wendelin.core/-/blob/wendelin.core-2.0.alpha3-26-g79e6f7b9/wcfs/wcfs.go#L1536-1591

if δFtail.BlkRevAt would return an error, then f.watchMu was not
RUnlocked back, and wg.Wait was not called at all.

-> Fix that by scheduling unlock and wg wait right after f.watchMu is
   rlocked and workgroup is created.

Test is, hopefully, TODO.

My mistake from 6f0cdaff (wcfs: Provide isolation to clients)

/reviewed-by @levin.zimmermann
/reviewed-on nexedi/wendelin.core!18
parent b20a26cb
...@@ -1548,8 +1548,15 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb ...@@ -1548,8 +1548,15 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb
blkrevRough := true blkrevRough := true
wg := xsync.NewWorkGroup(ctx) wg := xsync.NewWorkGroup(ctx)
defer func() {
err2 := wg.Wait()
if err == nil {
err = err2
}
}()
f.watchMu.RLock() f.watchMu.RLock()
defer f.watchMu.RUnlock()
for w := range f.watchTab { for w := range f.watchTab {
w := w w := w
...@@ -1600,9 +1607,8 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb ...@@ -1600,9 +1607,8 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb
return w.pin(ctx, blk, pinrev) return w.pin(ctx, blk, pinrev)
}) })
} }
f.watchMu.RUnlock()
return wg.Wait() return nil
} }
// setupWatch sets up or updates a Watch when client sends `watch <file> @<at>` request. // setupWatch sets up or updates a Watch when client sends `watch <file> @<at>` request.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment