summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/vfs
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
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')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/README.md2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/lock.go14
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go57
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go3
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go59
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go38
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_unix_lock.go108
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go32
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm.go4
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go2
12 files changed, 159 insertions, 164 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/README.md b/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
index 741a1b6a4..b1d9ea227 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
@@ -46,7 +46,7 @@ to check if your build supports file locking.
### Write-Ahead Logging
-On 64-bit Unix, this module uses `mmap` to implement
+On 64-bit little-endian Unix, this module uses `mmap` to implement
[shared-memory for the WAL-index](https://sqlite.org/wal.html#implementation_of_shared_memory_for_the_wal_index),
like SQLite.
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go b/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
index 5366fdb71..890684169 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
@@ -75,19 +75,7 @@ func (f *vfsFile) Lock(lock LockLevel) error {
if f.lock <= LOCK_NONE || f.lock >= LOCK_EXCLUSIVE {
panic(util.AssertErr())
}
- reserved := f.lock == LOCK_RESERVED
- // A PENDING lock is needed before acquiring an EXCLUSIVE lock.
- if f.lock < LOCK_PENDING {
- // If we're already RESERVED, we can block indefinitely,
- // since only incoming readers may briefly hold the PENDING lock.
- if rc := osGetPendingLock(f.File, reserved /* block */); rc != _OK {
- return rc
- }
- f.lock = LOCK_PENDING
- }
- // We are now PENDING, so we're just waiting for readers to leave.
- // If we were RESERVED, we can block for a bit before invoking the busy handler.
- if rc := osGetExclusiveLock(f.File, reserved /* block */); rc != _OK {
+ if rc := osGetExclusiveLock(f.File, &f.lock); rc != _OK {
return rc
}
f.lock = LOCK_EXCLUSIVE
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)
+}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go
index 487f0c7d9..6ecb60edb 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go
@@ -1,4 +1,4 @@
-//go:build (amd64 || arm64 || riscv64) && !sqlite3_nosys
+//go:build (amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_nosys
package vfs
@@ -9,6 +9,7 @@ import (
)
const (
+ // https://godbolt.org/z/1PcK5vea3
_F2FS_IOC_START_ATOMIC_WRITE = 62721
_F2FS_IOC_COMMIT_ATOMIC_WRITE = 62722
_F2FS_IOC_ABORT_ATOMIC_WRITE = 62725
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go
new file mode 100644
index 000000000..15730fe62
--- /dev/null
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go
@@ -0,0 +1,59 @@
+//go:build (linux || darwin) && !(sqlite3_flock || sqlite3_nosys)
+
+package vfs
+
+import (
+ "os"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+func osGetSharedLock(file *os.File) _ErrorCode {
+ // Test the PENDING lock before acquiring a new SHARED lock.
+ if lock, _ := osTestLock(file, _PENDING_BYTE, 1); lock == unix.F_WRLCK {
+ return _BUSY
+ }
+ // Acquire the SHARED lock.
+ return osReadLock(file, _SHARED_FIRST, _SHARED_SIZE, 0)
+}
+
+func osGetReservedLock(file *os.File) _ErrorCode {
+ // Acquire the RESERVED lock.
+ return osWriteLock(file, _RESERVED_BYTE, 1, 0)
+}
+
+func osGetExclusiveLock(file *os.File, state *LockLevel) _ErrorCode {
+ if *state == LOCK_RESERVED {
+ // A PENDING lock is needed before acquiring an EXCLUSIVE lock.
+ if rc := osWriteLock(file, _PENDING_BYTE, 1, -1); rc != _OK {
+ return rc
+ }
+ *state = LOCK_PENDING
+ }
+ // Acquire the EXCLUSIVE lock.
+ return osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, time.Millisecond)
+}
+
+func osDowngradeLock(file *os.File, state LockLevel) _ErrorCode {
+ if state >= LOCK_EXCLUSIVE {
+ // Downgrade to a SHARED lock.
+ if rc := osReadLock(file, _SHARED_FIRST, _SHARED_SIZE, 0); rc != _OK {
+ // notest // this should never happen
+ return _IOERR_RDLOCK
+ }
+ }
+ // Release the PENDING and RESERVED locks.
+ return osUnlock(file, _PENDING_BYTE, 2)
+}
+
+func osReleaseLock(file *os.File, _ LockLevel) _ErrorCode {
+ // Release all locks.
+ return osUnlock(file, 0, 0)
+}
+
+func osCheckReservedLock(file *os.File) (bool, _ErrorCode) {
+ // Test the RESERVED lock.
+ lock, rc := osTestLock(file, _RESERVED_BYTE, 1)
+ return lock == unix.F_WRLCK, rc
+}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go
index ecaff0245..c3590a7d5 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_atomic.go
@@ -1,4 +1,4 @@
-//go:build !linux || !(amd64 || arm64 || riscv64) || sqlite3_nosys
+//go:build !linux || !(amd64 || arm64 || riscv64 || ppc64le) || sqlite3_nosys
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go
index bf4b44efd..111af799a 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go
@@ -31,3 +31,41 @@ func osSetMode(file *os.File, modeof string) error {
}
return nil
}
+
+func osTestLock(file *os.File, start, len int64) (int16, _ErrorCode) {
+ lock := unix.Flock_t{
+ Type: unix.F_WRLCK,
+ Start: start,
+ Len: len,
+ }
+ if unix.FcntlFlock(file.Fd(), unix.F_GETLK, &lock) != nil {
+ return 0, _IOERR_CHECKRESERVEDLOCK
+ }
+ return lock.Type, _OK
+}
+
+func osLockErrorCode(err error, def _ErrorCode) _ErrorCode {
+ if err == nil {
+ return _OK
+ }
+ if errno, ok := err.(unix.Errno); ok {
+ switch errno {
+ case
+ unix.EACCES,
+ unix.EAGAIN,
+ unix.EBUSY,
+ unix.EINTR,
+ unix.ENOLCK,
+ unix.EDEADLK,
+ unix.ETIMEDOUT:
+ return _BUSY
+ case unix.EPERM:
+ return _PERM
+ }
+ // notest // usually EWOULDBLOCK == EAGAIN
+ if errno == unix.EWOULDBLOCK && unix.EWOULDBLOCK != unix.EAGAIN {
+ return _BUSY
+ }
+ }
+ return def
+}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix_lock.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix_lock.go
deleted file mode 100644
index 2616a0f5e..000000000
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix_lock.go
+++ /dev/null
@@ -1,108 +0,0 @@
-//go:build (linux || darwin || freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock) && !sqlite3_nosys
-
-package vfs
-
-import (
- "os"
- "time"
-
- "golang.org/x/sys/unix"
-)
-
-func osGetSharedLock(file *os.File) _ErrorCode {
- // Test the PENDING lock before acquiring a new SHARED lock.
- if lock, _ := osGetLock(file, _PENDING_BYTE, 1); lock == unix.F_WRLCK {
- return _BUSY
- }
- // Acquire the SHARED lock.
- return osReadLock(file, _SHARED_FIRST, _SHARED_SIZE, 0)
-}
-
-func osGetReservedLock(file *os.File) _ErrorCode {
- // Acquire the RESERVED lock.
- return osWriteLock(file, _RESERVED_BYTE, 1, 0)
-}
-
-func osGetPendingLock(file *os.File, block bool) _ErrorCode {
- var timeout time.Duration
- if block {
- timeout = -1
- }
- // Acquire the PENDING lock.
- return osWriteLock(file, _PENDING_BYTE, 1, timeout)
-}
-
-func osGetExclusiveLock(file *os.File, block bool) _ErrorCode {
- var timeout time.Duration
- if block {
- timeout = time.Millisecond
- }
- // Acquire the EXCLUSIVE lock.
- return osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, timeout)
-}
-
-func osDowngradeLock(file *os.File, state LockLevel) _ErrorCode {
- if state >= LOCK_EXCLUSIVE {
- // Downgrade to a SHARED lock.
- if rc := osReadLock(file, _SHARED_FIRST, _SHARED_SIZE, 0); rc != _OK {
- // In theory, the downgrade to a SHARED cannot fail because another
- // process is holding an incompatible lock. If it does, this
- // indicates that the other process is not following the locking
- // protocol. If this happens, return IOERR_RDLOCK. Returning
- // BUSY would confuse the upper layer.
- // notest
- return _IOERR_RDLOCK
- }
- }
- // Release the PENDING and RESERVED locks.
- return osUnlock(file, _PENDING_BYTE, 2)
-}
-
-func osReleaseLock(file *os.File, _ LockLevel) _ErrorCode {
- // Release all locks.
- return osUnlock(file, 0, 0)
-}
-
-func osCheckReservedLock(file *os.File) (bool, _ErrorCode) {
- // Test the RESERVED lock.
- lock, rc := osGetLock(file, _RESERVED_BYTE, 1)
- return lock == unix.F_WRLCK, rc
-}
-
-func osGetLock(file *os.File, start, len int64) (int16, _ErrorCode) {
- lock := unix.Flock_t{
- Type: unix.F_WRLCK,
- Start: start,
- Len: len,
- }
- if unix.FcntlFlock(file.Fd(), unix.F_GETLK, &lock) != nil {
- return 0, _IOERR_CHECKRESERVEDLOCK
- }
- return lock.Type, _OK
-}
-
-func osLockErrorCode(err error, def _ErrorCode) _ErrorCode {
- if err == nil {
- return _OK
- }
- if errno, ok := err.(unix.Errno); ok {
- switch errno {
- case
- unix.EACCES,
- unix.EAGAIN,
- unix.EBUSY,
- unix.EINTR,
- unix.ENOLCK,
- unix.EDEADLK,
- unix.ETIMEDOUT:
- return _BUSY
- case unix.EPERM:
- return _PERM
- }
- // notest // usually EWOULDBLOCK == EAGAIN
- if errno == unix.EWOULDBLOCK && unix.EWOULDBLOCK != unix.EAGAIN {
- return _BUSY
- }
- }
- return def
-}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go
index 4cad777d3..4f6149ba3 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go
@@ -28,27 +28,25 @@ func osGetReservedLock(file *os.File) _ErrorCode {
return osWriteLock(file, _RESERVED_BYTE, 1, 0)
}
-func osGetPendingLock(file *os.File, block bool) _ErrorCode {
- var timeout time.Duration
- if block {
- timeout = -1
- }
-
- // Acquire the PENDING lock.
- return osWriteLock(file, _PENDING_BYTE, 1, timeout)
-}
-
-func osGetExclusiveLock(file *os.File, block bool) _ErrorCode {
- var timeout time.Duration
- if block {
- timeout = time.Millisecond
+func osGetExclusiveLock(file *os.File, state *LockLevel) _ErrorCode {
+ // A PENDING lock is needed before releasing the SHARED lock.
+ if *state < LOCK_PENDING {
+ // If we were RESERVED, we can block indefinitely.
+ var timeout time.Duration
+ if *state == LOCK_RESERVED {
+ timeout = -1
+ }
+ if rc := osWriteLock(file, _PENDING_BYTE, 1, timeout); rc != _OK {
+ return rc
+ }
+ *state = LOCK_PENDING
}
// Release the SHARED lock.
osUnlock(file, _SHARED_FIRST, _SHARED_SIZE)
// Acquire the EXCLUSIVE lock.
- rc := osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, timeout)
+ rc := osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, time.Millisecond)
if rc != _OK {
// Reacquire the SHARED lock.
@@ -64,9 +62,7 @@ func osDowngradeLock(file *os.File, state LockLevel) _ErrorCode {
// Reacquire the SHARED lock.
if rc := osReadLock(file, _SHARED_FIRST, _SHARED_SIZE, 0); rc != _OK {
- // This should never happen.
- // We should always be able to reacquire the read lock.
- // notest
+ // notest // this should never happen
return _IOERR_RDLOCK
}
}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go
index 36f55d0b6..0fbd09d0a 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go
@@ -1,4 +1,4 @@
-//go:build (darwin || linux) && (amd64 || arm64 || riscv64) && !(sqlite3_flock || sqlite3_noshm || sqlite3_nosys)
+//go:build (darwin || linux) && (amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_flock || sqlite3_noshm || sqlite3_nosys)
package vfs
@@ -70,7 +70,7 @@ func (s *vfsShm) shmOpen() _ErrorCode {
}
// Dead man's switch.
- if lock, rc := osGetLock(s.File, _SHM_DMS, 1); rc != _OK {
+ if lock, rc := osTestLock(s.File, _SHM_DMS, 1); rc != _OK {
return _IOERR_LOCK
} else if lock == unix.F_WRLCK {
return _BUSY
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 089401156..52ffeacb5 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go
@@ -1,4 +1,4 @@
-//go:build (freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock) && (amd64 || arm64 || riscv64) && !(sqlite3_noshm || sqlite3_nosys)
+//go:build (freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock) && (amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_noshm || sqlite3_nosys)
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go
index 7c8997581..4d0f6a2ca 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go
@@ -1,4 +1,4 @@
-//go:build !(darwin || linux || freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock) || !(amd64 || arm64 || riscv64) || sqlite3_noshm || sqlite3_nosys
+//go:build !(darwin || linux || freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock) || !(amd64 || arm64 || riscv64 || ppc64le) || sqlite3_noshm || sqlite3_nosys
package vfs