aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <Dan Kennedy>2024-11-25 18:47:12 +0000
committerdan <Dan Kennedy>2024-11-25 18:47:12 +0000
commitf6d267491cc0d453b7c6dddc4fdfadaf1285f40b (patch)
tree28327471ccb7ae5003a5bb5d08d0f0baed6209f8 /src
parent1743c5f8369a58b90d212be840b12d88c658f47c (diff)
downloadsqlite-f6d267491cc0d453b7c6dddc4fdfadaf1285f40b.tar.gz
sqlite-f6d267491cc0d453b7c6dddc4fdfadaf1285f40b.zip
Ensure that file-handle winShmNode.hFile.h is used in a thread-safe manner.
FossilOrigin-Name: 7a32b497ab16774021924a8536e1025a0a01740a6484f0de17623a69713511d8
Diffstat (limited to 'src')
-rw-r--r--src/os_win.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/os_win.c b/src/os_win.c
index be13d8348..e7ed66858 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -2579,7 +2579,9 @@ static int winLockFileTimeout(
ret = winLockFile(&hFile, flags, offset, 0, nByte, 0);
#else
if( !osIsNT() ){
+ sqlite3_mutex_enter(pMutex);
ret = winLockFile(&hFile, flags, offset, 0, nByte, 0);
+ sqlite3_mutex_leave(pMutex);
}else{
OVERLAPPED ovlp;
memset(&ovlp, 0, sizeof(OVERLAPPED));
@@ -2593,7 +2595,10 @@ static int winLockFileTimeout(
flags &= ~LOCKFILE_FAIL_IMMEDIATELY;
}
+ sqlite3_mutex_enter(pMutex);
ret = osLockFileEx(hFile, flags, 0, nByte, 0, &ovlp);
+ sqlite3_mutex_leave(pMutex);
+
if( !ret && nMs>0 && GetLastError()==ERROR_IO_PENDING ){
DWORD res = WaitForSingleObject(ovlp.hEvent, (DWORD)nMs);
if( res==WAIT_OBJECT_0 ){