summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-09-30 12:46:23 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-30 12:46:23 +0200
commit188d28f054dbc9d8897a99d2213d8895922fc330 (patch)
tree2691665ad2e129ed7a07ea468024cc7db5005a54 /vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
parent[bugfix] Carry-over "PinnedAt" when refreshing status (#3373) (diff)
downloadgotosocial-188d28f054dbc9d8897a99d2213d8895922fc330.tar.xz
[chore]: Bump github.com/ncruces/go-sqlite3 from 0.18.3 to 0.18.4 (#3375)
Bumps [github.com/ncruces/go-sqlite3](https://github.com/ncruces/go-sqlite3) from 0.18.3 to 0.18.4. - [Release notes](https://github.com/ncruces/go-sqlite3/releases) - [Commits](https://github.com/ncruces/go-sqlite3/compare/v0.18.3...v0.18.4) --- updated-dependencies: - dependency-name: github.com/ncruces/go-sqlite3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go57
1 files changed, 39 insertions, 18 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
index 9f3c99daf..1f54a6929 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
@@ -4,31 +4,15 @@ package vfs
import (
"os"
- "time"
"golang.org/x/sys/unix"
)
-func osUnlock(file *os.File, start, len int64) _ErrorCode {
- if start == 0 && len == 0 {
- err := unix.Flock(int(file.Fd()), unix.LOCK_UN)
- if err != nil {
- return _IOERR_UNLOCK
- }
- }
- return _OK
-}
-
-func osLock(file *os.File, how int, def _ErrorCode) _ErrorCode {
- err := unix.Flock(int(file.Fd()), how)
- return osLockErrorCode(err, def)
-}
-
-func osReadLock(file *os.File, _ /*start*/, _ /*len*/ int64, _ /*timeout*/ time.Duration) _ErrorCode {
+func osGetSharedLock(file *os.File) _ErrorCode {
return osLock(file, unix.LOCK_SH|unix.LOCK_NB, _IOERR_RDLOCK)
}
-func osWriteLock(file *os.File, _ /*start*/, _ /*len*/ int64, _ /*timeout*/ time.Duration) _ErrorCode {
+func osGetReservedLock(file *os.File) _ErrorCode {
rc := osLock(file, unix.LOCK_EX|unix.LOCK_NB, _IOERR_LOCK)
if rc == _BUSY {
// The documentation states the lock is upgraded by releasing the previous lock,
@@ -38,3 +22,40 @@ func osWriteLock(file *os.File, _ /*start*/, _ /*len*/ int64, _ /*timeout*/ time
}
return rc
}
+
+func osGetExclusiveLock(file *os.File, state *LockLevel) _ErrorCode {
+ if *state >= LOCK_RESERVED {
+ return _OK
+ }
+ return osGetReservedLock(file)
+}
+
+func osDowngradeLock(file *os.File, _ LockLevel) _ErrorCode {
+ rc := osLock(file, unix.LOCK_SH|unix.LOCK_NB, _IOERR_RDLOCK)
+ if rc == _BUSY {
+ // The documentation states the lock is upgraded by releasing the previous lock,
+ // then acquiring the new lock.
+ // This is a race, so return IOERR_RDLOCK to ensure the transaction is aborted.
+ return _IOERR_RDLOCK
+ }
+ return _OK
+}
+
+func osReleaseLock(file *os.File, _ LockLevel) _ErrorCode {
+ err := unix.Flock(int(file.Fd()), unix.LOCK_UN)
+ if err != nil {
+ return _IOERR_UNLOCK
+ }
+ return _OK
+}
+
+func osCheckReservedLock(file *os.File) (bool, _ErrorCode) {
+ // Test the RESERVED lock.
+ lock, rc := osTestLock(file, _RESERVED_BYTE, 1)
+ return lock == unix.F_WRLCK, rc
+}
+
+func osLock(file *os.File, how int, def _ErrorCode) _ErrorCode {
+ err := unix.Flock(int(file.Fd()), how)
+ return osLockErrorCode(err, def)
+}