summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/vfs')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/README.md1
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/lock.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_f2fs_linux.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_std.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go2
-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_std_sync.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go45
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_bsd.go4
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go12
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go3
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go14
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_other.go2
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go14
22 files changed, 74 insertions, 49 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/README.md b/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
index 08777972e..354f8bf33 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/README.md
@@ -91,7 +91,6 @@ The implementation is compatible with SQLite's
The VFS can be customized with a few build tags:
- `sqlite3_flock` forces the use of BSD locks.
- `sqlite3_dotlk` forces the use of dot-file locks.
-- `sqlite3_nosys` prevents importing [`x/sys`](https://pkg.go.dev/golang.org/x/sys).
> [!IMPORTANT]
> The default configuration of this package is compatible with the standard
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go b/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
index 22e320a81..8828662d4 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/lock.go
@@ -1,4 +1,4 @@
-//go:build ((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && !sqlite3_nosys) || sqlite3_flock || sqlite3_dotlk
+//go:build linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock || sqlite3_dotlk
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go b/vendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go
index 81aacc622..9bdfa3cf2 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/lock_other.go
@@ -1,4 +1,4 @@
-//go:build !(((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && !sqlite3_nosys) || sqlite3_flock || sqlite3_dotlk)
+//go:build !(linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos || sqlite3_flock || sqlite3_dotlk)
package vfs
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 cc5da7cab..fa13ef3ae 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_bsd.go
@@ -1,4 +1,4 @@
-//go:build ((freebsd || openbsd || netbsd || dragonfly || illumos) && !(sqlite3_dotlk || sqlite3_nosys)) || sqlite3_flock
+//go:build ((freebsd || openbsd || netbsd || dragonfly || illumos) && !sqlite3_dotlk) || sqlite3_flock
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go
index c8d84dc36..7d809b223 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_darwin.go
@@ -1,4 +1,4 @@
-//go:build !(sqlite3_flock || sqlite3_nosys)
+//go:build !sqlite3_flock
package vfs
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 07bf0a047..36614309d 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
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
index e163e804d..f5841fc20 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_linux.go
@@ -1,4 +1,4 @@
-//go:build !(sqlite3_flock || sqlite3_nosys)
+//go:build !sqlite3_flock
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go
index b4f570f4d..d93050e8a 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_ofd.go
@@ -1,4 +1,4 @@
-//go:build (linux || darwin) && !(sqlite3_flock || sqlite3_dotlk || sqlite3_nosys)
+//go:build (linux || darwin) && !(sqlite3_flock || sqlite3_dotlk)
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std.go
index 87ce58b67..a17893d2e 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std.go
@@ -1,4 +1,4 @@
-//go:build !unix || sqlite3_nosys
+//go:build !unix
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go
index 60c92182c..4dd1bb32c 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_alloc.go
@@ -1,4 +1,4 @@
-//go:build !(linux || darwin) || sqlite3_flock || sqlite3_nosys
+//go:build !(linux || darwin) || sqlite3_flock
package vfs
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..10a0c8470 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)
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_sync.go b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_sync.go
index 84dbd23bc..b32e83e08 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_sync.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_std_sync.go
@@ -1,4 +1,4 @@
-//go:build !(linux || darwin) || sqlite3_flock || sqlite3_nosys
+//go:build !(linux || darwin) || sqlite3_flock
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 7a540889b..6637c2922 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_unix.go
@@ -1,4 +1,4 @@
-//go:build unix && !sqlite3_nosys
+//go:build unix
package vfs
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 0b6e5d342..2872201b0 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/os_windows.go
@@ -1,9 +1,8 @@
-//go:build !(sqlite3_dotlk || sqlite3_nosys)
+//go:build !sqlite3_dotlk
package vfs
import (
- "math/rand"
"os"
"time"
@@ -46,7 +45,7 @@ func osGetExclusiveLock(file *os.File, state *LockLevel) _ErrorCode {
osUnlock(file, _SHARED_FIRST, _SHARED_SIZE)
// Acquire the EXCLUSIVE lock.
- rc := osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, time.Millisecond)
+ rc := osWriteLock(file, _SHARED_FIRST, _SHARED_SIZE, 0)
if rc != _OK {
// Reacquire the SHARED lock.
@@ -123,29 +122,40 @@ func osLock(file *os.File, flags, start, len uint32, timeout time.Duration, def
var err error
switch {
case timeout == 0:
- err = osLockEx(file, flags|windows.LOCKFILE_FAIL_IMMEDIATELY, start, len)
+ err = osLockEx(file, flags|windows.LOCKFILE_FAIL_IMMEDIATELY, start, len, 0)
case timeout < 0:
- err = osLockEx(file, flags, start, len)
+ err = osLockEx(file, flags, start, len, 0)
default:
- before := time.Now()
- for {
- err = osLockEx(file, flags|windows.LOCKFILE_FAIL_IMMEDIATELY, start, len)
- if errno, _ := err.(windows.Errno); errno != windows.ERROR_LOCK_VIOLATION {
- break
+ var event windows.Handle
+ event, err = windows.CreateEvent(nil, 1, 0, nil)
+ if err != nil {
+ break
+ }
+ defer windows.CloseHandle(event)
+
+ err = osLockEx(file, flags, start, len, event)
+ if err == windows.ERROR_IO_PENDING {
+ rc, serr := windows.WaitForSingleObject(event, uint32(timeout/time.Millisecond))
+ if rc == windows.WAIT_OBJECT_0 {
+ return _OK
}
- if time.Since(before) > timeout {
- break
+ if serr != nil {
+ err = serr
+ } else {
+ err = windows.Errno(rc)
}
- const sleepIncrement = 1024*1024 - 1 // power of two, ~1ms
- time.Sleep(time.Duration(rand.Int63() & sleepIncrement))
+ windows.CancelIo(windows.Handle(file.Fd()))
}
}
return osLockErrorCode(err, def)
}
-func osLockEx(file *os.File, flags, start, len uint32) error {
+func osLockEx(file *os.File, flags, start, len uint32, event windows.Handle) error {
return windows.LockFileEx(windows.Handle(file.Fd()), flags,
- 0, len, 0, &windows.Overlapped{Offset: start})
+ 0, len, 0, &windows.Overlapped{
+ Offset: start,
+ HEvent: event,
+ })
}
func osReadLock(file *os.File, start, len uint32, timeout time.Duration) _ErrorCode {
@@ -166,7 +176,8 @@ func osLockErrorCode(err error, def _ErrorCode) _ErrorCode {
case
windows.ERROR_LOCK_VIOLATION,
windows.ERROR_IO_PENDING,
- windows.ERROR_OPERATION_ABORTED:
+ windows.ERROR_OPERATION_ABORTED,
+ windows.WAIT_TIMEOUT:
return _BUSY
}
}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm.go
index 9d9dff1c4..f28955289 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 ((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_nosys) || sqlite3_flock || sqlite3_dotlk
+//go:build ((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le)) || sqlite3_flock || sqlite3_dotlk
package vfs
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 07cabf7b5..8e7f27084 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) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_dotlk || sqlite3_nosys)) || sqlite3_flock
+//go:build ((freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_dotlk) || sqlite3_flock
package vfs
@@ -73,7 +73,7 @@ func (s *vfsShm) shmOpen() _ErrorCode {
// Always open file read-write, as it will be shared.
f, err := os.OpenFile(s.path,
- unix.O_RDWR|unix.O_CREAT|unix.O_NOFOLLOW, 0666)
+ os.O_RDWR|os.O_CREATE|_O_NOFOLLOW, 0666)
if err != nil {
return _CANTOPEN
}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go
index e6007aa1c..db8ddb4b8 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_copy.go
@@ -1,4 +1,4 @@
-//go:build (windows && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_nosys) || sqlite3_dotlk
+//go:build (windows && (386 || arm || amd64 || arm64 || riscv64 || ppc64le)) || sqlite3_dotlk
package vfs
@@ -13,7 +13,7 @@ const (
_WALINDEX_PGSZ = 32768
)
-// This looks like a safe way of keeping the WAL-index in sync.
+// This seems a safe way of keeping the WAL-index in sync.
//
// The WAL-index file starts with a header,
// and the index doesn't meaningfully change if the header doesn't change.
@@ -27,7 +27,7 @@ const (
//
// Since all the data is either redundant+checksummed,
// 4 byte aligned, or modified under an exclusive lock,
-// the copies below should correctly keep copies in sync.
+// the copies below should correctly keep memory in sync.
//
// https://sqlite.org/walformat.html#the_wal_index_file_format
@@ -35,7 +35,7 @@ func (s *vfsShm) shmAcquire(ptr *_ErrorCode) {
if ptr != nil && *ptr != _OK {
return
}
- if len(s.ptrs) == 0 || shmUnmodified(s.shadow[0][:], s.shared[0][:]) {
+ if len(s.ptrs) == 0 || shmEqual(s.shadow[0][:], s.shared[0][:]) {
return
}
// Copies modified words from shared to private memory.
@@ -53,7 +53,7 @@ func (s *vfsShm) shmAcquire(ptr *_ErrorCode) {
}
func (s *vfsShm) shmRelease() {
- if len(s.ptrs) == 0 || shmUnmodified(s.shadow[0][:], util.View(s.mod, s.ptrs[0], _WALINDEX_HDR_SIZE)) {
+ if len(s.ptrs) == 0 || shmEqual(s.shadow[0][:], util.View(s.mod, s.ptrs[0], _WALINDEX_HDR_SIZE)) {
return
}
// Copies modified words from private to shared memory.
@@ -82,6 +82,6 @@ func shmPage(s []byte) *[_WALINDEX_PGSZ / 4]uint32 {
return (*[_WALINDEX_PGSZ / 4]uint32)(unsafe.Slice(p, _WALINDEX_PGSZ/4))
}
-func shmUnmodified(v1, v2 []byte) bool {
+func shmEqual(v1, v2 []byte) bool {
return *(*[_WALINDEX_HDR_SIZE]byte)(v1[:]) == *(*[_WALINDEX_HDR_SIZE]byte)(v2[:])
}
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go
index 4c7f47dec..e302db7e6 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_dotlk.go
@@ -9,8 +9,9 @@ import (
"os"
"sync"
- "github.com/ncruces/go-sqlite3/internal/util"
"github.com/tetratelabs/wazero/api"
+
+ "github.com/ncruces/go-sqlite3/internal/util"
)
type vfsShmParent struct {
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go
index dc7b91350..404019642 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_memlk.go
@@ -1,4 +1,4 @@
-//go:build ((freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_nosys) || sqlite3_flock || sqlite3_dotlk
+//go:build ((freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le)) || sqlite3_flock || sqlite3_dotlk
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go
index 75c8fbcfb..d335a85fc 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_ofd.go
@@ -1,4 +1,4 @@
-//go:build (linux || darwin) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_flock || sqlite3_dotlk || sqlite3_nosys)
+//go:build (linux || darwin) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_flock || sqlite3_dotlk)
package vfs
@@ -20,6 +20,7 @@ type vfsShm struct {
path string
regions []*util.MappedRegion
readOnly bool
+ fileLock bool
blocking bool
sync.Mutex
}
@@ -29,10 +30,10 @@ var _ blockingSharedMemory = &vfsShm{}
func (s *vfsShm) shmOpen() _ErrorCode {
if s.File == nil {
f, err := os.OpenFile(s.path,
- unix.O_RDWR|unix.O_CREAT|unix.O_NOFOLLOW, 0666)
+ os.O_RDWR|os.O_CREATE|_O_NOFOLLOW, 0666)
if err != nil {
f, err = os.OpenFile(s.path,
- unix.O_RDONLY|unix.O_CREAT|unix.O_NOFOLLOW, 0666)
+ os.O_RDONLY|os.O_CREATE|_O_NOFOLLOW, 0666)
s.readOnly = true
}
if err != nil {
@@ -40,6 +41,9 @@ func (s *vfsShm) shmOpen() _ErrorCode {
}
s.File = f
}
+ if s.fileLock {
+ return _OK
+ }
// Dead man's switch.
if lock, rc := osTestLock(s.File, _SHM_DMS, 1); rc != _OK {
@@ -64,7 +68,9 @@ func (s *vfsShm) shmOpen() _ErrorCode {
return _IOERR_SHMOPEN
}
}
- return osReadLock(s.File, _SHM_DMS, 1, time.Millisecond)
+ rc := osReadLock(s.File, _SHM_DMS, 1, time.Millisecond)
+ s.fileLock = rc == _OK
+ return rc
}
func (s *vfsShm) shmMap(ctx context.Context, mod api.Module, id, size int32, extend bool) (uint32, _ErrorCode) {
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 9602dd0cd..69319f07d 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 !(((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_nosys) || sqlite3_flock || sqlite3_dotlk)
+//go:build !(((linux || darwin || windows || freebsd || openbsd || netbsd || dragonfly || illumos) && (386 || arm || amd64 || arm64 || riscv64 || ppc64le)) || sqlite3_flock || sqlite3_dotlk)
package vfs
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go
index 374d491ac..1de57640c 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/shm_windows.go
@@ -1,4 +1,4 @@
-//go:build (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !(sqlite3_dotlk || sqlite3_nosys)
+//go:build (386 || arm || amd64 || arm64 || riscv64 || ppc64le) && !sqlite3_dotlk
package vfs
@@ -7,6 +7,7 @@ import (
"io"
"os"
"sync"
+ "syscall"
"time"
"github.com/tetratelabs/wazero/api"
@@ -27,6 +28,7 @@ type vfsShm struct {
shadow [][_WALINDEX_PGSZ]byte
ptrs []uint32
stack [1]uint64
+ fileLock bool
blocking bool
sync.Mutex
}
@@ -46,12 +48,16 @@ func (s *vfsShm) Close() error {
func (s *vfsShm) shmOpen() _ErrorCode {
if s.File == nil {
- f, err := osutil.OpenFile(s.path, os.O_RDWR|os.O_CREATE, 0666)
+ f, err := osutil.OpenFile(s.path,
+ os.O_RDWR|os.O_CREATE|syscall.O_NONBLOCK, 0666)
if err != nil {
return _CANTOPEN
}
s.File = f
}
+ if s.fileLock {
+ return _OK
+ }
// Dead man's switch.
if rc := osWriteLock(s.File, _SHM_DMS, 1, 0); rc == _OK {
@@ -61,7 +67,9 @@ func (s *vfsShm) shmOpen() _ErrorCode {
return _IOERR_SHMOPEN
}
}
- return osReadLock(s.File, _SHM_DMS, 1, time.Millisecond)
+ rc := osReadLock(s.File, _SHM_DMS, 1, time.Millisecond)
+ s.fileLock = rc == _OK
+ return rc
}
func (s *vfsShm) shmMap(ctx context.Context, mod api.Module, id, size int32, extend bool) (_ uint32, rc _ErrorCode) {