Commit 4a2070da authored by Kirill Smelkov's avatar Kirill Smelkov

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)
parent 979c9c22
......@@ -1548,8 +1548,15 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb
blkrevRough := true
wg := xsync.NewWorkGroup(ctx)
defer func() {
err2 := wg.Wait()
if err == nil {
err = err2
}
}()
f.watchMu.RLock()
defer f.watchMu.RUnlock()
for w := range f.watchTab {
w := w
......@@ -1600,9 +1607,8 @@ func (f *BigFile) readPinWatchers(ctx context.Context, blk int64, blkrevMax zodb
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.
......
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