File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -631,13 +631,11 @@ func (dh *DirHandle) listObjectsFlat() (start string, err error) {
631631 }
632632 } else {
633633 // We must release dh.mu before calling sealDir to avoid deadlock
634- // Save the current generation before unlocking
635- currentGen := atomic .LoadUint64 (& dh .inode .dir .generation )
636634 dh .mu .Unlock ()
637635 dh .inode .sealDir ()
638636 dh .mu .Lock ()
639637 // Update our generation to match the new state
640- dh .generation = currentGen + 1 // We know it was incremented in sealDir
638+ dh .generation = atomic . LoadUint64 ( & dh . inode . dir . generation )
641639 }
642640
643641 dh .inode .mu .Unlock ()
@@ -649,6 +647,9 @@ func (dh *DirHandle) listObjectsFlat() (start string, err error) {
649647// LOCKS_REQUIRED(dh.inode.mu)
650648func (dh * DirHandle ) checkDirPosition () {
651649 // Check if directory structure changed since we last checked
650+ // Note: There's a benign race here where generation could change between
651+ // the load and assignment. This is acceptable as we'll catch it on the
652+ // next operation. The worst case is an unnecessary position reset.
652653 currentGen := atomic .LoadUint64 (& dh .inode .dir .generation )
653654 if dh .generation != currentGen {
654655 dh .lastInternalOffset = - 1
You can’t perform that action at this time.
0 commit comments