]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Compile fixes and improvements for vxwork: fixed deadlock in semClose,
authorchw <chw@noemail.net>
Tue, 7 Apr 2009 05:35:03 +0000 (05:35 +0000)
committerchw <chw@noemail.net>
Tue, 7 Apr 2009 05:35:03 +0000 (05:35 +0000)
detect if fcntl is usable, fall back to named semaphores if not. (CVS 6460)

FossilOrigin-Name: efd0682b7e78acc4242cf257fc246350fc29b5c8

manifest
manifest.uuid
src/os_unix.c

index 7e3d07b121cd60e361da803f19a287eb18908e00..cd7a03cffaff3ffa1e7eb02e8e0b0a0372db1552 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sunused\stest\sfor\sEXPLAIN-mode\sin\sthe\sPRAGMA\sprocessing.\s(CVS\s6459)
-D 2009-04-07T00:49:16
+C Compile\sfixes\sand\simprovements\sfor\svxwork:\sfixed\sdeadlock\sin\ssemClose,\ndetect\sif\sfcntl\sis\susable,\sfall\sback\sto\snamed\ssemaphores\sif\snot.\s(CVS\s6460)
+D 2009-04-07T05:35:04
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -141,7 +141,7 @@ F src/os.c c2aa4a7d8bb845222e5c37f56cde377b20c3b087
 F src/os.h fa3f4aa0119ff721a2da4b47ffd74406ac864c05
 F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
-F src/os_unix.c e5eef59cfb0f646b5010bc597b7c4a91534efc9b
+F src/os_unix.c 9ad9f45049a3c9eb0b0713b162ff0d7024ff7259
 F src/os_win.c 524fe4c31c469531191857e8036ef59bfb52d684
 F src/pager.c 1df277b7c78f780df119c9e2ddea6690979489c5
 F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f
@@ -715,7 +715,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 567cf90b038a37da93d02954ef8f9f435dcc9a38
-R 9fccbb587b2c9a284607fd3746a1335c
-U drh
-Z aac902d0bf43c86a2936f0bc5216ba03
+P 909683b3428784ce91d222ccf887033d86250bd5
+R 1644d97c76c8c923de903afaae7ff2f3
+U chw
+Z 32650e63af9e81b186aac6c919550d61
index 3f2c6dfc82c47a6998360354d22a0bfeee4284be..785a9211998e8cfde6d6e2fd950b97d2518a8b73 100644 (file)
@@ -1 +1 @@
-909683b3428784ce91d222ccf887033d86250bd5
\ No newline at end of file
+efd0682b7e78acc4242cf257fc246350fc29b5c8
\ No newline at end of file
index 75f595326fc1638a0cbcef5dd91d339803127a25..8776acaa5ec7d51d2c216f5fbde0c68353f27dfd 100644 (file)
@@ -43,7 +43,7 @@
 **   *  Definitions of sqlite3_vfs objects for all locking methods
 **      plus implementations of sqlite3_os_init() and sqlite3_os_end().
 **
-** $Id: os_unix.c,v 1.249 2009/04/07 00:35:20 drh Exp $
+** $Id: os_unix.c,v 1.250 2009/04/07 05:35:04 chw Exp $
 */
 #include "sqliteInt.h"
 #if SQLITE_OS_UNIX              /* This file is used on unix only */
@@ -2213,8 +2213,8 @@ static int semClose(sqlite3_file *id) {
     unixEnterMutex();
     releaseLockInfo(pFile->pLock);
     releaseOpenCnt(pFile->pOpen);
-    closeUnixFile(id);
     unixLeaveMutex();
+    closeUnixFile(id);
   }
   return SQLITE_OK;
 }
@@ -3207,7 +3207,7 @@ IOMETHODS(
   dotlockCheckReservedLock  /* xCheckReservedLock method */
 )
 
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
 IOMETHODS(
   flockIoFinder,            /* Finder function name */
   flockIoMethods,           /* sqlite3_io_methods object name */
@@ -3331,6 +3331,44 @@ static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
 
 #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
 
+#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
+/* 
+** This "finder" function attempts to determine the best locking strategy 
+** for the database file "filePath".  It then returns the sqlite3_io_methods
+** object that implements that strategy.
+**
+** This is for VXWorks only.
+*/
+static const sqlite3_io_methods *autolockIoFinderImpl(
+  const char *filePath,    /* name of the database file */
+  int fd                   /* file descriptor open on the database file */
+){
+  struct flock lockInfo;
+
+  if( !filePath ){
+    /* If filePath==NULL that means we are dealing with a transient file
+    ** that does not need to be locked. */
+    return &nolockIoMethods;
+  }
+
+  /* Test if fcntl() is supported and use POSIX style locks.
+  ** Otherwise fall back to the named semaphore method.
+  */
+  lockInfo.l_len = 1;
+  lockInfo.l_start = 0;
+  lockInfo.l_whence = SEEK_SET;
+  lockInfo.l_type = F_RDLCK;
+  if( fcntl(fd, F_GETLK, &lockInfo)!=-1 ) {
+    return &posixIoMethods;
+  }else{
+    return &semIoMethods;
+  }
+}
+static const sqlite3_io_methods *(*const autolockIoFinder)(const char*,int)
+        = autolockIoFinderImpl;
+
+#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
+
 /*
 ** An abstract type for a pointer to a IO method finder function:
 */
@@ -5061,7 +5099,7 @@ int sqlite3_os_init(void){
   ** array cannot be const.
   */
   static sqlite3_vfs aVfs[] = {
-#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
+#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
     UNIXVFS("unix",          autolockIoFinder ),
 #else
     UNIXVFS("unix",          posixIoFinder ),
@@ -5073,8 +5111,10 @@ int sqlite3_os_init(void){
 #endif
 #if SQLITE_ENABLE_LOCKING_STYLE
     UNIXVFS("unix-posix",    posixIoFinder ),
+#if !OS_VXWORKS
     UNIXVFS("unix-flock",    flockIoFinder ),
 #endif
+#endif
 #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
     UNIXVFS("unix-afp",      afpIoFinder ),
     UNIXVFS("unix-proxy",    proxyIoFinder ),