mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Simplifications to the locking logic in the unix-dotfile VFS.
FossilOrigin-Name: 583813525888c7e106f3e8cb46c1a507006daee6
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\sthe\ssqldiff\sutility\sprogram\sso\sthat\sit\sworks\sfor\sschemas\sthat\shave\ntables\swith\szero-length\scolumn\snames.
|
C Simplifications\sto\sthe\slocking\slogic\sin\sthe\sunix-dotfile\sVFS.
|
||||||
D 2015-11-29T21:46:19.675
|
D 2015-11-30T00:05:39.456
|
||||||
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
|
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc e928e68168df69b353300ac87c10105206653a03
|
F Makefile.msc e928e68168df69b353300ac87c10105206653a03
|
||||||
@@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
|
|||||||
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
|
||||||
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
|
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
|
||||||
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
|
||||||
F src/os_unix.c 951ef130fd491531d03f4ab07ba4ac4df7861364
|
F src/os_unix.c d4ca37d4fa3d65d2d553751f147e61276f5e06bf
|
||||||
F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811
|
F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811
|
||||||
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
|
||||||
F src/pager.c f92aacd5216d8815136c9e0190041783c602641a
|
F src/pager.c f92aacd5216d8815136c9e0190041783c602641a
|
||||||
@@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P d6e177fd09c83d46adc5b5d36e9a439aa5397450
|
P 64263ccb8f9835c615242de6e28db24f953422fa
|
||||||
R 6d96f803f67943fdc4d03a972304e707
|
R dc472c39e1975a0a69aca2b2404edc3d
|
||||||
U drh
|
U drh
|
||||||
Z e1ff9fd256204ded8600114936035e27
|
Z 57f1db7fea7d09de3a215136ff8d3a37
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
64263ccb8f9835c615242de6e28db24f953422fa
|
583813525888c7e106f3e8cb46c1a507006daee6
|
||||||
@@ -1350,6 +1350,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
|
|||||||
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
|
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
|
||||||
|
|
||||||
assert( pFile );
|
assert( pFile );
|
||||||
|
assert( pFile->eFileLock<=SHARED_LOCK );
|
||||||
unixEnterMutex(); /* Because pFile->pInode is shared across threads */
|
unixEnterMutex(); /* Because pFile->pInode is shared across threads */
|
||||||
|
|
||||||
/* Check if a thread in this process holds such a lock */
|
/* Check if a thread in this process holds such a lock */
|
||||||
@@ -1760,9 +1761,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
|
|||||||
if( unixFileLock(pFile, &lock)==(-1) ){
|
if( unixFileLock(pFile, &lock)==(-1) ){
|
||||||
tErrno = errno;
|
tErrno = errno;
|
||||||
rc = SQLITE_IOERR_UNLOCK;
|
rc = SQLITE_IOERR_UNLOCK;
|
||||||
if( IS_LOCK_ERROR(rc) ){
|
storeLastErrno(pFile, tErrno);
|
||||||
storeLastErrno(pFile, tErrno);
|
|
||||||
}
|
|
||||||
goto end_unlock;
|
goto end_unlock;
|
||||||
}
|
}
|
||||||
lock.l_type = F_RDLCK;
|
lock.l_type = F_RDLCK;
|
||||||
@@ -1784,9 +1783,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
|
|||||||
if( unixFileLock(pFile, &lock)==(-1) ){
|
if( unixFileLock(pFile, &lock)==(-1) ){
|
||||||
tErrno = errno;
|
tErrno = errno;
|
||||||
rc = SQLITE_IOERR_UNLOCK;
|
rc = SQLITE_IOERR_UNLOCK;
|
||||||
if( IS_LOCK_ERROR(rc) ){
|
storeLastErrno(pFile, tErrno);
|
||||||
storeLastErrno(pFile, tErrno);
|
|
||||||
}
|
|
||||||
goto end_unlock;
|
goto end_unlock;
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
@@ -2037,17 +2034,7 @@ static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
|
|||||||
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
|
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
|
||||||
|
|
||||||
assert( pFile );
|
assert( pFile );
|
||||||
|
reserved = osAccess((const char*)pFile->lockingContext, 0)==0;
|
||||||
/* Check if a thread in this process holds such a lock */
|
|
||||||
if( pFile->eFileLock>SHARED_LOCK ){
|
|
||||||
/* Either this connection or some other connection in the same process
|
|
||||||
** holds a lock on the file. No need to check further. */
|
|
||||||
reserved = 1;
|
|
||||||
}else{
|
|
||||||
/* The lock is held if and only if the lockfile exists */
|
|
||||||
const char *zLockFile = (const char*)pFile->lockingContext;
|
|
||||||
reserved = osAccess(zLockFile, 0)==0;
|
|
||||||
}
|
|
||||||
OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved));
|
OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, rc, reserved));
|
||||||
*pResOut = reserved;
|
*pResOut = reserved;
|
||||||
return rc;
|
return rc;
|
||||||
@@ -2109,7 +2096,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
|
|||||||
rc = SQLITE_BUSY;
|
rc = SQLITE_BUSY;
|
||||||
} else {
|
} else {
|
||||||
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
|
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
|
||||||
if( IS_LOCK_ERROR(rc) ){
|
if( rc!=SQLITE_BUSY ){
|
||||||
storeLastErrno(pFile, tErrno);
|
storeLastErrno(pFile, tErrno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2156,14 +2143,12 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
|
|||||||
/* To fully unlock the database, delete the lock file */
|
/* To fully unlock the database, delete the lock file */
|
||||||
assert( eFileLock==NO_LOCK );
|
assert( eFileLock==NO_LOCK );
|
||||||
rc = osRmdir(zLockFile);
|
rc = osRmdir(zLockFile);
|
||||||
if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile);
|
|
||||||
if( rc<0 ){
|
if( rc<0 ){
|
||||||
int tErrno = errno;
|
int tErrno = errno;
|
||||||
rc = 0;
|
if( tErrno==ENOENT ){
|
||||||
if( ENOENT != tErrno ){
|
rc = SQLITE_OK;
|
||||||
|
}else{
|
||||||
rc = SQLITE_IOERR_UNLOCK;
|
rc = SQLITE_IOERR_UNLOCK;
|
||||||
}
|
|
||||||
if( IS_LOCK_ERROR(rc) ){
|
|
||||||
storeLastErrno(pFile, tErrno);
|
storeLastErrno(pFile, tErrno);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@@ -2176,14 +2161,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
|
|||||||
** Close a file. Make sure the lock has been released before closing.
|
** Close a file. Make sure the lock has been released before closing.
|
||||||
*/
|
*/
|
||||||
static int dotlockClose(sqlite3_file *id) {
|
static int dotlockClose(sqlite3_file *id) {
|
||||||
int rc = SQLITE_OK;
|
unixFile *pFile = (unixFile*)id;
|
||||||
if( id ){
|
assert( id!=0 );
|
||||||
unixFile *pFile = (unixFile*)id;
|
dotlockUnlock(id, NO_LOCK);
|
||||||
dotlockUnlock(id, NO_LOCK);
|
sqlite3_free(pFile->lockingContext);
|
||||||
sqlite3_free(pFile->lockingContext);
|
return closeUnixFile(id);
|
||||||
rc = closeUnixFile(id);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
/****************** End of the dot-file lock implementation *******************
|
/****************** End of the dot-file lock implementation *******************
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@@ -2249,10 +2231,8 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
|
|||||||
int tErrno = errno;
|
int tErrno = errno;
|
||||||
/* unlock failed with an error */
|
/* unlock failed with an error */
|
||||||
lrc = SQLITE_IOERR_UNLOCK;
|
lrc = SQLITE_IOERR_UNLOCK;
|
||||||
if( IS_LOCK_ERROR(lrc) ){
|
storeLastErrno(pFile, tErrno);
|
||||||
storeLastErrno(pFile, tErrno);
|
rc = lrc;
|
||||||
rc = lrc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int tErrno = errno;
|
int tErrno = errno;
|
||||||
@@ -2385,12 +2365,9 @@ static int flockUnlock(sqlite3_file *id, int eFileLock) {
|
|||||||
** Close a file.
|
** Close a file.
|
||||||
*/
|
*/
|
||||||
static int flockClose(sqlite3_file *id) {
|
static int flockClose(sqlite3_file *id) {
|
||||||
int rc = SQLITE_OK;
|
assert( id!=0 );
|
||||||
if( id ){
|
flockUnlock(id, NO_LOCK);
|
||||||
flockUnlock(id, NO_LOCK);
|
return closeUnixFile(id);
|
||||||
rc = closeUnixFile(id);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */
|
#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */
|
||||||
@@ -3015,23 +2992,22 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) {
|
|||||||
*/
|
*/
|
||||||
static int afpClose(sqlite3_file *id) {
|
static int afpClose(sqlite3_file *id) {
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
if( id ){
|
unixFile *pFile = (unixFile*)id;
|
||||||
unixFile *pFile = (unixFile*)id;
|
assert( id!=0 );
|
||||||
afpUnlock(id, NO_LOCK);
|
afpUnlock(id, NO_LOCK);
|
||||||
unixEnterMutex();
|
unixEnterMutex();
|
||||||
if( pFile->pInode && pFile->pInode->nLock ){
|
if( pFile->pInode && pFile->pInode->nLock ){
|
||||||
/* If there are outstanding locks, do not actually close the file just
|
/* If there are outstanding locks, do not actually close the file just
|
||||||
** yet because that would clear those locks. Instead, add the file
|
** yet because that would clear those locks. Instead, add the file
|
||||||
** descriptor to pInode->aPending. It will be automatically closed when
|
** descriptor to pInode->aPending. It will be automatically closed when
|
||||||
** the last lock is cleared.
|
** the last lock is cleared.
|
||||||
*/
|
*/
|
||||||
setPendingFd(pFile);
|
setPendingFd(pFile);
|
||||||
}
|
|
||||||
releaseInodeInfo(pFile);
|
|
||||||
sqlite3_free(pFile->lockingContext);
|
|
||||||
rc = closeUnixFile(id);
|
|
||||||
unixLeaveMutex();
|
|
||||||
}
|
}
|
||||||
|
releaseInodeInfo(pFile);
|
||||||
|
sqlite3_free(pFile->lockingContext);
|
||||||
|
rc = closeUnixFile(id);
|
||||||
|
unixLeaveMutex();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7374,7 +7350,7 @@ static int proxyUnlock(sqlite3_file *id, int eFileLock) {
|
|||||||
** Close a file that uses proxy locks.
|
** Close a file that uses proxy locks.
|
||||||
*/
|
*/
|
||||||
static int proxyClose(sqlite3_file *id) {
|
static int proxyClose(sqlite3_file *id) {
|
||||||
if( id ){
|
if( ALWAYS(id) ){
|
||||||
unixFile *pFile = (unixFile*)id;
|
unixFile *pFile = (unixFile*)id;
|
||||||
proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;
|
proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;
|
||||||
unixFile *lockProxy = pCtx->lockProxy;
|
unixFile *lockProxy = pCtx->lockProxy;
|
||||||
|
|||||||
Reference in New Issue
Block a user