aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mutex_w32.c16
-rw-r--r--src/os_unix.c1
-rw-r--r--src/os_win.c20
3 files changed, 14 insertions, 23 deletions
diff --git a/src/mutex_w32.c b/src/mutex_w32.c
index 7b411018f..7eb5b50be 100644
--- a/src/mutex_w32.c
+++ b/src/mutex_w32.c
@@ -314,12 +314,22 @@ static int winMutexTry(sqlite3_mutex *p){
/*
** The sqlite3_mutex_try() routine is very rarely used, and when it
** is used it is merely an optimization. So it is OK for it to always
- ** fail on some platforms. But - it is required for ENABLE_SETLK_TIMEOUT
- ** builds.
+ ** fail.
+ **
+ ** The TryEnterCriticalSection() interface is only available on WinNT.
+ ** And some windows compilers complain if you try to use it without
+ ** first doing some #defines that prevent SQLite from building on Win98.
+ ** For that reason, we will omit this optimization for now. See
+ ** ticket #2685.
*/
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400
assert( winMutex_isInit==1 );
- if( sqlite3_win32_is_nt() && TryEnterCriticalSection(&p->mutex) ){
+ assert( winMutex_isNt>=-1 && winMutex_isNt<=1 );
+ if( winMutex_isNt<0 ){
+ winMutex_isNt = sqlite3_win32_is_nt();
+ }
+ assert( winMutex_isNt==0 || winMutex_isNt==1 );
+ if( winMutex_isNt && TryEnterCriticalSection(&p->mutex) ){
#ifdef SQLITE_DEBUG
p->owner = tid;
p->nRef++;
diff --git a/src/os_unix.c b/src/os_unix.c
index 77855a8dd..b1996278c 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4290,6 +4290,7 @@ static int unixGetpagesize(void){
**
** nRef
**
+** The following fields are read-only after the object is created:
**
** hShm
** zFilename
diff --git a/src/os_win.c b/src/os_win.c
index a02b0c535..c042ac162 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -3874,25 +3874,6 @@ static int winShmMutexHeld(void) {
** Either winShmNode.mutex must be held or winShmNode.nRef==0 and
** winShmMutexHeld() is true when reading or writing any other field
** in this structure.
-**
-** aMutex[SQLITE_SHM_NLOCK]:
-** Normally, when SQLITE_ENABLE_SETLK_TIMEOUT is not defined, mutex
-** winShmNode.mutex is used to serialize calls to the xShmLock()
-** method.
-**
-** For SQLITE_ENABLE_SETLK_TIMEOUT builds, xShmLock() only takes the
-** mutexes in the aMutex[] array that correspond to locks being taken
-** or released. This means that:
-**
-** * Modifying the winShmNode.pFirst list requires holding *all*
-** the locks in the aMutex[] array.
-**
-** * Reads and writes to winShm.sharedMask and winShm.exclMask must
-** use AtomicLoad() and AtomicStore(). This is because it may be
-** read by other threads while it is being modified.
-**
-** TODO: winShmNode.mutex is held for the space of time when LockFileEx()
-** is called on winShmNode.hFile.
*/
struct winShmNode {
sqlite3_mutex *mutex; /* Mutex to access this object */
@@ -3913,7 +3894,6 @@ struct winShmNode {
int nRef; /* Number of winShm objects pointing to this */
winShm *pFirst; /* All winShm objects pointing to this */
winShmNode *pNext; /* Next in list of all winShmNode objects */
-
#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
u8 nextShmId; /* Next available winShm.id value */
#endif