Skip to content

Commit

Permalink
Imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Nov 27, 2024
1 parent 4ede2c7 commit 1469cb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions vfs/shm_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -27,15 +27,15 @@ 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

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.
Expand All @@ -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.
Expand Down Expand Up @@ -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[:])
}
3 changes: 2 additions & 1 deletion vfs/shm_dotlk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1469cb9

Please sign in to comment.