From 81b66ad7e324dda72abc293433ecdaf4cf55c3a6 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:30:55 +0000 Subject: update ncruces/go-sqlite3 v0.21.3 -> v0.22.0, gruf/go-ffmpreg v0.6.4 -> v0.6.5 (#3646) --- vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go') diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go index 5f4f5d108..76e6888e1 100644 --- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go +++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go @@ -178,7 +178,7 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode { s.Lock() defer s.Unlock() - // Check if we could obtain/release the lock locally. + // Check if we can obtain/release locks locally. rc := s.shmMemLock(offset, n, flags) if rc != _OK { return rc @@ -187,6 +187,8 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode { // Obtain/release the appropriate file locks. switch { case flags&_SHM_UNLOCK != 0: + // Relasing a shared lock decrements the counter, + // but may leave parts of the range still locked. begin, end := offset, offset+n for i := begin; i < end; i++ { if s.vfsShmParent.lock[i] != 0 { @@ -201,14 +203,22 @@ func (s *vfsShm) shmLock(offset, n int32, flags _ShmFlag) _ErrorCode { } return rc case flags&_SHM_SHARED != 0: - rc = osReadLock(s.File, _SHM_BASE+int64(offset), int64(n)) + // Acquiring a new shared lock on the file is only necessary + // if there was a new shared lock in the range. + for i := offset; i < offset+n; i++ { + if s.vfsShmParent.lock[i] == 1 { + rc = osReadLock(s.File, _SHM_BASE+int64(offset), int64(n)) + break + } + } case flags&_SHM_EXCLUSIVE != 0: + // Acquiring an exclusive lock on the file is always necessary. rc = osWriteLock(s.File, _SHM_BASE+int64(offset), int64(n)) default: panic(util.AssertErr()) } - // Release the local lock we had acquired. + // Release the local locks we had acquired. if rc != _OK { s.shmMemLock(offset, n, flags^(_SHM_UNLOCK|_SHM_LOCK)) } -- cgit v1.2.3