|
@@ -14,7 +14,7 @@ import (
|
|
|
// 历史坑: 原设计锁偏移=0 直接锁头页 (页 0), Windows NTFS 页粒度锁 (4KB) 会让
|
|
// 历史坑: 原设计锁偏移=0 直接锁头页 (页 0), Windows NTFS 页粒度锁 (4KB) 会让
|
|
|
// 任何 Pread 页 0 返回零数据, 连锁持有方自己 ReadAt 也中招 —— 引擎 ReadHeader
|
|
// 任何 Pread 页 0 返回零数据, 连锁持有方自己 ReadAt 也中招 —— 引擎 ReadHeader
|
|
|
// 拿到 FirstWALPage=0, RecoverWAL 整个空转。
|
|
// 拿到 FirstWALPage=0, RecoverWAL 整个空转。
|
|
|
-const lockByteCount = 1
|
|
|
|
|
|
|
+// 实际值见 const.go FileLockByteCount。
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
winLockFileExclusive = 0x00000002 // LOCKFILE_EXCLUSIVE_LOCK
|
|
winLockFileExclusive = 0x00000002 // LOCKFILE_EXCLUSIVE_LOCK
|
|
@@ -79,7 +79,7 @@ func (ff *File) tryLock() error {
|
|
|
uintptr(h),
|
|
uintptr(h),
|
|
|
uintptr(winLockFileExclusive|winLockFileFailImmediately),
|
|
uintptr(winLockFileExclusive|winLockFileFailImmediately),
|
|
|
0,
|
|
0,
|
|
|
- uintptr(lockByteCount),
|
|
|
|
|
|
|
+ uintptr(FileLockByteCount),
|
|
|
0,
|
|
0,
|
|
|
uintptr(unsafe.Pointer(ol)))
|
|
uintptr(unsafe.Pointer(ol)))
|
|
|
if r1 == 0 {
|
|
if r1 == 0 {
|
|
@@ -113,7 +113,7 @@ func (ff *File) tryRLock() error {
|
|
|
uintptr(h),
|
|
uintptr(h),
|
|
|
uintptr(winLockFileFailImmediately), // 共享锁 (无 LOCKFILE_EXCLUSIVE_LOCK)
|
|
uintptr(winLockFileFailImmediately), // 共享锁 (无 LOCKFILE_EXCLUSIVE_LOCK)
|
|
|
0,
|
|
0,
|
|
|
- uintptr(lockByteCount),
|
|
|
|
|
|
|
+ uintptr(FileLockByteCount),
|
|
|
0,
|
|
0,
|
|
|
uintptr(unsafe.Pointer(ol)))
|
|
uintptr(unsafe.Pointer(ol)))
|
|
|
if r1 == 0 {
|
|
if r1 == 0 {
|
|
@@ -138,7 +138,7 @@ func (ff *File) unlock() {
|
|
|
_, _, _ = syscall.Syscall6(procUnlockFileEx.Addr(), 5,
|
|
_, _, _ = syscall.Syscall6(procUnlockFileEx.Addr(), 5,
|
|
|
uintptr(h),
|
|
uintptr(h),
|
|
|
0,
|
|
0,
|
|
|
- uintptr(lockByteCount),
|
|
|
|
|
|
|
+ uintptr(FileLockByteCount),
|
|
|
0,
|
|
0,
|
|
|
uintptr(unsafe.Pointer(ol)),
|
|
uintptr(unsafe.Pointer(ol)),
|
|
|
0)
|
|
0)
|