Skip to content

Commit d5583b6

Browse files
committed
Try to fix flaky test.
1 parent 3649c10 commit d5583b6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

vfs/shm_bsd.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,28 @@ func (s *vfsShm) Close() error {
7272
return nil
7373
}
7474

75-
// Unlock everything.
76-
s.shmLock(0, _SHM_NLOCK, _SHM_UNLOCK)
77-
7875
vfsShmFilesMtx.Lock()
7976
defer vfsShmFilesMtx.Unlock()
8077

78+
// Unlock everything.
79+
s.shmLock(0, _SHM_NLOCK, _SHM_UNLOCK)
80+
8181
// Decrease reference count.
8282
if s.vfsShmFile.refs > 1 {
8383
s.vfsShmFile.refs--
8484
s.vfsShmFile = nil
8585
return nil
8686
}
87+
88+
err := s.File.Close()
8789
for i, g := range vfsShmFiles {
8890
if g == s.vfsShmFile {
8991
vfsShmFiles[i] = nil
90-
break
92+
s.vfsShmFile = nil
93+
return err
9194
}
9295
}
93-
94-
err := s.File.Close()
95-
s.vfsShmFile = nil
96-
return err
96+
panic(util.AssertErr())
9797
}
9898

9999
func (s *vfsShm) shmOpen() (rc _ErrorCode) {
@@ -234,6 +234,8 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode {
234234
s.vfsShmFile.lock[i] = -1
235235
s.lock[i] = true
236236
}
237+
default:
238+
panic(util.AssertErr())
237239
}
238240

239241
return _OK
@@ -256,5 +258,4 @@ func (s *vfsShm) shmUnmap(delete bool) {
256258
os.Remove(s.path)
257259
}
258260
s.Close()
259-
s.vfsShmFile = nil
260261
}

0 commit comments

Comments
 (0)