@@ -22,7 +22,7 @@ type vfsShmParent struct {
22
22
23
23
refs int // +checklocks:vfsShmListMtx
24
24
25
- lock [_SHM_NLOCK ]int16 // +checklocks:Mutex
25
+ lock [_SHM_NLOCK ]int8 // +checklocks:Mutex
26
26
sync.Mutex
27
27
}
28
28
@@ -184,10 +184,22 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode {
184
184
return rc
185
185
}
186
186
187
- // Obtain/release the appropriate file lock .
187
+ // Obtain/release the appropriate file locks .
188
188
switch {
189
189
case flags & _SHM_UNLOCK != 0 :
190
- return osUnlock (s .File , _SHM_BASE + int64 (offset ), int64 (n ))
190
+ begin , end := offset , offset + n
191
+ for i := begin ; i < end ; i ++ {
192
+ if s .vfsShmParent .lock [i ] != 0 {
193
+ if i > begin {
194
+ rc |= osUnlock (s .File , _SHM_BASE + int64 (begin ), int64 (i - begin ))
195
+ }
196
+ begin = i + 1
197
+ }
198
+ }
199
+ if end > begin {
200
+ rc |= osUnlock (s .File , _SHM_BASE + int64 (begin ), int64 (end - begin ))
201
+ }
202
+ return rc
191
203
case flags & _SHM_SHARED != 0 :
192
204
rc = osReadLock (s .File , _SHM_BASE + int64 (offset ), int64 (n ))
193
205
case flags & _SHM_EXCLUSIVE != 0 :
@@ -196,7 +208,7 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode {
196
208
panic (util .AssertErr ())
197
209
}
198
210
199
- // Release the local lock.
211
+ // Reacquire the local lock.
200
212
if rc != _OK {
201
213
s .shmMemLock (offset , n , flags ^ (_SHM_UNLOCK | _SHM_LOCK ))
202
214
}
0 commit comments