[fdo-commits] r651 - trunk/Thirdparty/Sqlite3.1.5/Src

svn_fdo at osgeo.org svn_fdo at osgeo.org
Tue Jan 23 14:49:02 EST 2007


Author: badreddinekaroui
Date: 2007-01-23 14:49:02 -0500 (Tue, 23 Jan 2007)
New Revision: 651

Modified:
   trunk/Thirdparty/Sqlite3.1.5/Src/pager.c
Log:
Merging change 650 from branch 3.2.x to the trunk:
A deadlock can occur if an SDF reader is maintained open for an extended period while a writer thread tries to make an update. This deadlock happened when a grid control used a scrollable reader and left it open for the lifetime of the grid in order to scroll up and down.
The fix is to relax the use of the shared lock for the readers and only apply the lock when loading the first page.


Modified: trunk/Thirdparty/Sqlite3.1.5/Src/pager.c
===================================================================
--- trunk/Thirdparty/Sqlite3.1.5/Src/pager.c	2007-01-23 19:39:07 UTC (rev 650)
+++ trunk/Thirdparty/Sqlite3.1.5/Src/pager.c	2007-01-23 19:49:02 UTC (rev 651)
@@ -2249,6 +2249,11 @@
       if( rc!=SQLITE_OK ){
         return rc;
       }
+      // OSGeo change: leaving a lock may result in a deadlock if the user keeps a reader around
+      // Here we at least know there is no writer actively writing to the file(no exclusive lock). Not perfect but...
+      sqlite3OsUnlock(&pPager->fd, NO_LOCK);  
+      pPager->state = NO_LOCK;
+      // End OSGeo change
     }
 
     /* If a journal file exists, and there is no RESERVED lock on the
@@ -2642,7 +2647,16 @@
   Pager *pPager = pPg->pPager;
   int rc = SQLITE_OK;
   assert( pPg->nRef>0 );
-  assert( pPager->state!=PAGER_UNLOCK );
+  //assert( pPager->state!=PAGER_UNLOCK );
+  // Start OSGeo code
+  // We need to put the shared lock back(we may have remove it in sqlite3pager_get to avoid deadlocks).
+    if( pPager->state==PAGER_UNLOCK ){
+      rc = pager_wait_on_lock(pPager, SHARED_LOCK);
+      if( rc!=SQLITE_OK ){
+        return rc;
+      }
+    }
+  // End OSGeo code
   if( pPager->state==PAGER_SHARED ){
     assert( pPager->aInJournal==0 );
     if( MEMDB ){



More information about the fdo-commits mailing list