From 865050681a3f78ce87877a0adee059a041147b8b Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 5 Oct 2007 15:08:01 +0000 Subject: [PATCH] Do not attempt to use TryEnterCriticalSection() under win32. It causes too many compiler problems. Ticket #2685. (CVS 4471) FossilOrigin-Name: f795431c725d88bd4011f20cf63cac630de842f1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/mutex_w32.c | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 0502321682..d80f88fcd4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sproblem\sbuilding\stestfixture\son\smac.\sTicket\s#2689.\s(CVS\s4470) -D 2007-10-05T15:04:13 +C Do\snot\sattempt\sto\suse\sTryEnterCriticalSection()\sunder\swin32.\s\sIt\scauses\ntoo\smany\scompiler\sproblems.\s\sTicket\s#2685.\s(CVS\s4471) +D 2007-10-05T15:08:01 F Makefile.in 75b729d562e9525d57d9890ec598b38e1a8b02bc F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -108,7 +108,7 @@ F src/mutex.c 3259f62c2429967aee6dc112117a6d2f499ef061 F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb F src/mutex_os2.c 7fe4773e98ed74a63b2e54fc557929eb155f6269 F src/mutex_unix.c ff77650261a245035b79c5c8a174f4e05d3cae8a -F src/mutex_w32.c d2c56fb81aca10af1577bdae2a4083eb2505f8ee +F src/mutex_w32.c 6e197765f283815496193e78e9548b5d0e53b68e F src/os.c 6a84b6ff284fa558e879d9b6a5809004aacc8195 F src/os.h 4c880cf67437f323cd0c3ab2154f1d76babc12d3 F src/os_common.h 98862f120ca6bf7a48ce8b16f158b77d00bc9d2f @@ -581,7 +581,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P e65842a9d4c779d24207e8a7934fe3bf35ff228b -R b83859050d5b26cf66a470937c7295fe -U danielk1977 -Z 80bd2f8fe3f9e95b46cdb428645feda3 +P fe067d706b40d9756433eac9896660514d1c8216 +R da5eae15cf17bf50336e76f7b8e01006 +U drh +Z da16cefa553e529b7c5a0949638526d9 diff --git a/manifest.uuid b/manifest.uuid index 02d522ec76..4deb219743 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe067d706b40d9756433eac9896660514d1c8216 \ No newline at end of file +f795431c725d88bd4011f20cf63cac630de842f1 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index ee5a4088dd..1944ccc79c 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains the C functions that implement mutexes for win32 ** -** $Id: mutex_w32.c,v 1.4 2007/09/05 14:30:42 drh Exp $ +** $Id: mutex_w32.c,v 1.5 2007/10/05 15:08:01 drh Exp $ */ #include "sqliteInt.h" @@ -168,16 +168,27 @@ void sqlite3_mutex_enter(sqlite3_mutex *p){ p->nRef++; } int sqlite3_mutex_try(sqlite3_mutex *p){ - int rc; + int rc = SQLITE_BUSY; assert( p ); assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(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. + ** + ** 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 0 if( mutexIsNT() && TryEnterCriticalSection(&p->mutex) ){ p->owner = GetCurrentThreadId(); p->nRef++; rc = SQLITE_OK; - }else{ - rc = SQLITE_BUSY; } +#endif return rc; }