File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -68,16 +68,11 @@ func (s *vfsShm) Close() error {
6868 panic (util .AssertErr ())
6969}
7070
71- func (s * vfsShm ) shmOpen () _ErrorCode {
71+ func (s * vfsShm ) shmOpen () ( rc _ErrorCode ) {
7272 if s .vfsShmParent != nil {
7373 return _OK
7474 }
7575
76- var f * os.File
77- // Close file on error.
78- // Keep this here to avoid confusing checklocks.
79- defer func () { f .Close () }()
80-
8176 vfsShmListMtx .Lock ()
8277 defer vfsShmListMtx .Unlock ()
8378
@@ -98,11 +93,16 @@ func (s *vfsShm) shmOpen() _ErrorCode {
9893 }
9994
10095 // Always open file read-write, as it will be shared.
101- f , err = os .OpenFile (s .path ,
96+ f , err : = os .OpenFile (s .path ,
10297 os .O_RDWR | os .O_CREATE | _O_NOFOLLOW , 0666 )
10398 if err != nil {
10499 return _CANTOPEN
105100 }
101+ defer func () {
102+ if rc != _OK {
103+ f .Close ()
104+ }
105+ }()
106106
107107 // Dead man's switch.
108108 if lock , rc := osTestLock (f , _SHM_DMS , 1 ); rc != _OK {
@@ -131,7 +131,6 @@ func (s *vfsShm) shmOpen() _ErrorCode {
131131 File : f ,
132132 info : fi ,
133133 }
134- f = nil // Don't close the file.
135134 for i , g := range vfsShmList {
136135 if g == nil {
137136 vfsShmList [i ] = s .vfsShmParent
You can’t perform that action at this time.
0 commit comments