/ Check-in [348409de]
Login

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

Overview
Comment:Changes to the interface design for the xShmLock method of the VFS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: 348409de26eafe12f5cb1236e8e167a4183d4051
User & Date: drh 2010-04-28 17:21:33
Context
2010-04-28
17:49
Merge two "wal" leaves. check-in: 13d2d5a6 user: dan tags: wal
17:21
Changes to the interface design for the xShmLock method of the VFS. check-in: 348409de user: drh tags: wal
14:42
Rename the sqlite3_log_hook() to sqlite3_wal_hook(). Added comments to wal.h. check-in: bbc38511 user: drh tags: wal
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
}

/*
** Create or release a lock on shared memory.
*/
static int unixShmLock(
  sqlite3_shm *pSharedMem,   /* Pointer from unixShmOpen() */
  int lockType,              /* _RDLK, _WRLK, or _UNLK, possibly ORed _BLOCK */
  int ofst,                  /* Start of lock region */
  int nByte                  /* Size of lock region in bytes */
){
  struct unixShm *p = (struct unixShm*)pSharedMem;
  struct flock f;
  int op;
  int rc;
  
  f.l_whence = SEEK_SET;
  f.l_start = ofst;
  f.l_len = nByte;
  switch( lockType & 0x07 ){
    case SQLITE_SHM_RDLK:  f.l_type = F_RDLCK;   break;
    case SQLITE_SHM_WRLK:  f.l_type = F_WRLCK;   break;
    case SQLITE_SHM_UNLK:  f.l_type = F_UNLCK;   break;
  }
  op = (lockType & 0x08)!=0 ? F_SETLKW : F_SETLK;
  rc = fcntl(p->fd.h, op, &f);
  return (rc==0) ? SQLITE_OK : SQLITE_BUSY;
}

/*
** Delete a shared-memory segment from the system.
*/
static int unixShmDelete(sqlite3_vfs *pVfs, const char *zName){
  return pVfs->xDelete(pVfs, zName, 0);







|
|
|

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704















4705
4706
4707
4708
4709
4710
4711
}

/*
** Create or release a lock on shared memory.
*/
static int unixShmLock(
  sqlite3_shm *pSharedMem,   /* Pointer from unixShmOpen() */
  int desiredLock,           /* The locking state desired */
  int *pGotLock,             /* The locking state actually obtained */
  int shouldBlock            /* Block for the lock if true and possible */
){
  return SQLITE_OK;















}

/*
** Delete a shared-memory segment from the system.
*/
static int unixShmDelete(sqlite3_vfs *pVfs, const char *zName){
  return pVfs->xDelete(pVfs, zName, 0);

Changes to src/sqlite.h.in.

844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
...
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890

891

892
893
894


895
896
897
898
899
900
901
  ** definition.  Those that follow are added in version 2 or later
  */
  int (*xShmOpen)(sqlite3_vfs*, const char *zName, sqlite3_shm**);
  int (*xShmSize)(sqlite3_shm*, int reqSize, int *pNewSize, char**);
  int (*xShmRelease)(sqlite3_shm*);
  int (*xShmPush)(sqlite3_shm*);
  int (*xShmPull)(sqlite3_shm*);
  int (*xShmLock)(sqlite3_shm*, int lockType, int ofst, int nByte);
  int (*xShmClose)(sqlite3_shm*);
  int (*xShmDelete)(sqlite3_vfs*, const char *zName);
  int (*xRename)(sqlite3_vfs*, const char *zOld, const char *zNew, int dirSync);
  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
  /*
  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  ** New fields may be appended in figure versions.  The iVersion
................................................................................
#define SQLITE_ACCESS_EXISTS    0
#define SQLITE_ACCESS_READWRITE 1
#define SQLITE_ACCESS_READ      2

/*
** CAPI3REF: Flags for the xShmLock VFS method
**
** These integer constants can be used as the second parameter to
** the xShmLock method of an [sqlite3_vfs] object.  They determine
** the specific locking action.  Exactly one of the first three
** values must be used ini the lockType parameter.  The fourth
** value (SQLITE_SHM_BLOCK) can optionally be ORed into the lockType
** parameter to cause the thread to block until the lock becomes
** available.
*/

#define SQLITE_SHM_RDLK   0x01

#define SQLITE_SHM_WRLK   0x02
#define SQLITE_SHM_UNLK   0x04
#define SQLITE_SHM_BLOCK  0x08



/*
** CAPI3REF: Initialize The SQLite Library
**
** ^The sqlite3_initialize() routine initializes the
** SQLite library.  ^The sqlite3_shutdown() routine
** deallocates any resources that were allocated by sqlite3_initialize().







|







 







|
|
|
|
|
<
<

>
|
>
|
|
|
>
>







844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
...
876
877
878
879
880
881
882
883
884
885
886
887


888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
  ** definition.  Those that follow are added in version 2 or later
  */
  int (*xShmOpen)(sqlite3_vfs*, const char *zName, sqlite3_shm**);
  int (*xShmSize)(sqlite3_shm*, int reqSize, int *pNewSize, char**);
  int (*xShmRelease)(sqlite3_shm*);
  int (*xShmPush)(sqlite3_shm*);
  int (*xShmPull)(sqlite3_shm*);
  int (*xShmLock)(sqlite3_shm*, int desiredLock, int *gotLock, int shouldBlock);
  int (*xShmClose)(sqlite3_shm*);
  int (*xShmDelete)(sqlite3_vfs*, const char *zName);
  int (*xRename)(sqlite3_vfs*, const char *zOld, const char *zNew, int dirSync);
  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
  /*
  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  ** New fields may be appended in figure versions.  The iVersion
................................................................................
#define SQLITE_ACCESS_EXISTS    0
#define SQLITE_ACCESS_READWRITE 1
#define SQLITE_ACCESS_READ      2

/*
** CAPI3REF: Flags for the xShmLock VFS method
**
** These integer constants define the various locking states that
** an sqlite3_shm object can be in.  The SQLITE_SHM_QUERY integer
** is not a valid data - it is a constant pasted to the 
** sqlite3_vfs.xShmLock() method for querying the current lock
** state.


*/
#define SQLITE_SHM_UNLOCK       0
#define SQLITE_SHM_READ_PREFIX  1
#define SQLITE_SHM_READ_FULL    2
#define SQLITE_SHM_WRITE        3
#define SQLITE_SHM_PENDING      4
#define SQLITE_SHM_CHECKPOINT   5
#define SQLITE_SHM_RECOVER      6
#define SQLITE_SHM_QUERY        (-1)

/*
** CAPI3REF: Initialize The SQLite Library
**
** ^The sqlite3_initialize() routine initializes the
** SQLite library.  ^The sqlite3_shutdown() routine
** deallocates any resources that were allocated by sqlite3_initialize().