SQLite

Check-in [25fe7a42ec]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the SQLITE_BUSY_RESERVED_LOCK compile-time option. (CVS 1894)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 25fe7a42ec2e06e659d7a0a6664789114c007e17
User & Date: drh 2004-08-19 13:29:15.000
Context
2004-08-19
15:12
Enhance lemon so that a @X instead of just X in the code expands to the major token value rather than the minor token value. Use this to make the parser a few hundred bytes smaller. (CVS 1895) (check-in: 28215096e0 user: drh tags: trunk)
13:29
Add the SQLITE_BUSY_RESERVED_LOCK compile-time option. (CVS 1894) (check-in: 25fe7a42ec user: drh tags: trunk)
2004-08-18
19:09
Make sure the database file is correctly truncated after a ROLLBACK that occurs after a statement abort. (CVS 1893) (check-in: 6afe467d14 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.158 2004/08/18 19:09:44 drh Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.159 2004/08/19 13:29:15 drh Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>

2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430

2431
2432
2433
2434
2435
2436
2437
  assert( pPager->state!=PAGER_UNLOCK );
  if( pPager->state==PAGER_SHARED ){
    assert( pPager->aInJournal==0 );
    if( pPager->memDb ){
      pPager->state = PAGER_EXCLUSIVE;
      pPager->origDbSize = pPager->dbSize;
    }else{
#if 0
      int busy = 1;
      do {
        rc = sqlite3OsLock(&pPager->fd, RESERVED_LOCK);
      }while( rc==SQLITE_BUSY && 
          pPager->pBusyHandler && 
          pPager->pBusyHandler->xFunc && 
          pPager->pBusyHandler->xFunc(pPager->pBusyHandler->pArg, busy++)
      );
#endif
      rc = sqlite3OsLock(&pPager->fd, RESERVED_LOCK);

      if( rc!=SQLITE_OK ){
        /* We do not call the busy handler when we fail to get a reserved lock.
        ** The only reason we might fail is because another process is holding
        ** the reserved lock.  But the other process will not be able to
        ** release its reserved lock until this process releases its shared
        ** lock.  So we might as well fail in this process, let it release
        ** its shared lock so that the other process can commit.







|








|

>







2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
  assert( pPager->state!=PAGER_UNLOCK );
  if( pPager->state==PAGER_SHARED ){
    assert( pPager->aInJournal==0 );
    if( pPager->memDb ){
      pPager->state = PAGER_EXCLUSIVE;
      pPager->origDbSize = pPager->dbSize;
    }else{
#ifdef SQLITE_BUSY_RESERVED_LOCK
      int busy = 1;
      do {
        rc = sqlite3OsLock(&pPager->fd, RESERVED_LOCK);
      }while( rc==SQLITE_BUSY && 
          pPager->pBusyHandler && 
          pPager->pBusyHandler->xFunc && 
          pPager->pBusyHandler->xFunc(pPager->pBusyHandler->pArg, busy++)
      );
#else
      rc = sqlite3OsLock(&pPager->fd, RESERVED_LOCK);
#endif
      if( rc!=SQLITE_OK ){
        /* We do not call the busy handler when we fail to get a reserved lock.
        ** The only reason we might fail is because another process is holding
        ** the reserved lock.  But the other process will not be able to
        ** release its reserved lock until this process releases its shared
        ** lock.  So we might as well fail in this process, let it release
        ** its shared lock so that the other process can commit.