Changes to the interface design for the xShmLock method of the VFS.
FossilOrigin-Name: 348409de26eafe12f5cb1236e8e167a4183d4051
This commit is contained in:
+4
-19
@@ -4697,26 +4697,11 @@ static int unixShmRelease(sqlite3_shm *pSharedMem){
|
||||
*/
|
||||
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 */
|
||||
int desiredLock, /* The locking state desired */
|
||||
int *pGotLock, /* The locking state actually obtained */
|
||||
int shouldBlock /* Block for the lock if true and possible */
|
||||
){
|
||||
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;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+14
-12
@@ -848,7 +848,7 @@ struct sqlite3_vfs {
|
||||
int (*xShmRelease)(sqlite3_shm*);
|
||||
int (*xShmPush)(sqlite3_shm*);
|
||||
int (*xShmPull)(sqlite3_shm*);
|
||||
int (*xShmLock)(sqlite3_shm*, int lockType, int ofst, int nByte);
|
||||
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);
|
||||
@@ -880,18 +880,20 @@ struct sqlite3_vfs {
|
||||
/*
|
||||
** 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.
|
||||
** 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_RDLK 0x01
|
||||
#define SQLITE_SHM_WRLK 0x02
|
||||
#define SQLITE_SHM_UNLK 0x04
|
||||
#define SQLITE_SHM_BLOCK 0x08
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user