Updates to the locking-style code in os_unix.c. Not yet working. (CVS 4834)
FossilOrigin-Name: 6ebce3b798c60050fb3c583d805570bb06837108
This commit is contained in:
parent
98dc4b1aba
commit
218c508433
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Clean\sup\srecent\sautoconf-related\sadditions,\sadd\sconfig.h\sto\sthe\samalgamation\s(CVS\s4833)
|
||||
D 2008-03-06T16:28:58
|
||||
C Updates\sto\sthe\slocking-style\scode\sin\sos_unix.c.\s\sNot\syet\sworking.\s(CVS\s4834)
|
||||
D 2008-03-07T00:27:10
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in 724ca16b1b62dd123344b2945b906f9e6d922ff8
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -125,7 +125,7 @@ F src/os_os2.c 10b23539e0050bdfc9f136242086a5c18c70c6f8
|
||||
F src/os_os2.h c3f7d0af7e3453d1d7aa81b06c0a56f5a226530b
|
||||
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
|
||||
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
|
||||
F src/os_unix.c e4daef7628f690fa2b188af3632fb18f96525946
|
||||
F src/os_unix.c b21695b8cc529f9aad7507bdc0d31cfa72623159
|
||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||
F src/os_win.c aa3f4bbee3b8c182d25a33fbc319f486857c12c1
|
||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||
@ -623,7 +623,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P e2a9f5f1054f077e4773dd3d2c8f2ce5be118a01
|
||||
R 40dd63e8c23d267ba43a975ab562cefb
|
||||
U mlcreech
|
||||
Z 77eff1d0b0188f0cd2e341dd1c104736
|
||||
P 8044623062e9aa43593c46e3e5d5bc7361ea7418
|
||||
R 0ade21cdb2beced327069a3136a9d80f
|
||||
U drh
|
||||
Z 33a6ec815f80c4e0995bb3a35a490baa
|
||||
|
@ -1 +1 @@
|
||||
8044623062e9aa43593c46e3e5d5bc7361ea7418
|
||||
6ebce3b798c60050fb3c583d805570bb06837108
|
140
src/os_unix.c
140
src/os_unix.c
@ -1745,10 +1745,10 @@ static int afpUnixUnlock(sqlite3_file *id, int locktype) {
|
||||
** Close a file & cleanup AFP specific locking context
|
||||
*/
|
||||
static int afpUnixClose(sqlite3_file *id) {
|
||||
unixFile *pFile = (unixFile*)pId;
|
||||
unixFile *pFile = (unixFile*)id;
|
||||
|
||||
if( !pFile ) return SQLITE_OK;
|
||||
afpUnixUnlock(*pId, NO_LOCK);
|
||||
afpUnixUnlock(id, NO_LOCK);
|
||||
/* free the AFP locking structure */
|
||||
if (pFile->lockingContext != NULL) {
|
||||
if (((afpLockingContext *)pFile->lockingContext)->filePath != NULL)
|
||||
@ -1758,9 +1758,12 @@ static int afpUnixClose(sqlite3_file *id) {
|
||||
|
||||
if( pFile->dirfd>=0 ) close(pFile->dirfd);
|
||||
pFile->dirfd = -1;
|
||||
enterMutex();
|
||||
close(pFile->h);
|
||||
leaveMutex();
|
||||
OSTRACE2("CLOSE %-3d\n", pFile->h);
|
||||
OpenCounter(-1);
|
||||
memset(pFile, 0, sizeof(unixFile));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -1840,20 +1843,21 @@ static int flockUnixUnlock(sqlite3_file *id, int locktype) {
|
||||
/*
|
||||
** Close a file.
|
||||
*/
|
||||
static int flockUnixClose(sqlite3_file *pId) {
|
||||
unixFile *pFile = (unixFile*)*pId;
|
||||
static int flockUnixClose(sqlite3_file *id) {
|
||||
unixFile *pFile = (unixFile*)id;
|
||||
|
||||
if( !pFile ) return SQLITE_OK;
|
||||
flockUnixUnlock(*pId, NO_LOCK);
|
||||
flockUnixUnlock(id, NO_LOCK);
|
||||
|
||||
if( pFile->dirfd>=0 ) close(pFile->dirfd);
|
||||
pFile->dirfd = -1;
|
||||
enterMutex();
|
||||
|
||||
enterMutex();
|
||||
close(pFile->h);
|
||||
leaveMutex();
|
||||
OSTRACE2("CLOSE %-3d\n", pFile->h);
|
||||
OpenCounter(-1);
|
||||
memset(pFile, 0, sizeof(unixFile));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -1952,7 +1956,7 @@ static int dotlockUnixClose(sqlite3_file *id) {
|
||||
unixFile *pFile = (unixFile*)id;
|
||||
|
||||
if( !pFile ) return SQLITE_OK;
|
||||
dotlockUnixUnlock(*pId, NO_LOCK);
|
||||
dotlockUnixUnlock(id, NO_LOCK);
|
||||
/* free the dotlock locking structure */
|
||||
if (pFile->lockingContext != NULL) {
|
||||
if (((dotlockLockingContext *)pFile->lockingContext)->lockPath != NULL)
|
||||
@ -1964,12 +1968,11 @@ static int dotlockUnixClose(sqlite3_file *id) {
|
||||
if( pFile->dirfd>=0 ) close(pFile->dirfd);
|
||||
pFile->dirfd = -1;
|
||||
enterMutex();
|
||||
|
||||
close(pFile->h);
|
||||
|
||||
leaveMutex();
|
||||
OSTRACE2("CLOSE %-3d\n", pFile->h);
|
||||
OpenCounter(-1);
|
||||
memset(pFile, 0, sizeof(unixFile));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -2003,12 +2006,11 @@ static int nolockUnixClose(sqlite3_file *id) {
|
||||
if( pFile->dirfd>=0 ) close(pFile->dirfd);
|
||||
pFile->dirfd = -1;
|
||||
enterMutex();
|
||||
|
||||
close(pFile->h);
|
||||
|
||||
leaveMutex();
|
||||
OSTRACE2("CLOSE %-3d\n", pFile->h);
|
||||
OpenCounter(-1);
|
||||
memset(pFile, 0, sizeof(unixFile));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@ -2076,7 +2078,7 @@ static const sqlite3_io_methods sqlite3UnixIoMethod = {
|
||||
*/
|
||||
static const sqlite3_io_methods sqlite3AFPLockingUnixIoMethod = {
|
||||
1, /* iVersion */
|
||||
unixClose,
|
||||
afpUnixClose,
|
||||
unixRead,
|
||||
unixWrite,
|
||||
unixTruncate,
|
||||
@ -2167,22 +2169,26 @@ static const sqlite3_io_methods sqlite3NolockLockingUnixIoMethod = {
|
||||
static int fillInUnixFile(
|
||||
int h, /* Open file descriptor of file being opened */
|
||||
int dirfd, /* Directory file descriptor */
|
||||
sqlite3_file *pId, /* Write completed initialization here */
|
||||
const char *zFilename, /* Name of the file being opened */
|
||||
sqlite3_file *pId, /* Write to the unixFile structure here */
|
||||
const char *zFilename /* Name of the file being opened */
|
||||
){
|
||||
sqlite3LockingStyle lockingStyle;
|
||||
unixFile *pNew = (unixFile *)pId;
|
||||
int rc;
|
||||
|
||||
memset(pNew, 0, sizeof(unixFile));
|
||||
#ifdef FD_CLOEXEC
|
||||
fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
|
||||
#endif
|
||||
|
||||
lockingStyle = sqlite3DetectLockingStyle(zFilename, h);
|
||||
if ( lockingStyle == posixLockingStyle ) {
|
||||
|
||||
enterMutex();
|
||||
rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen);
|
||||
leaveMutex();
|
||||
if( rc ){
|
||||
if( dirfd>=0 ) close(dirfd);
|
||||
close(h);
|
||||
unlink(zFilename);
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
} else {
|
||||
@ -2190,65 +2196,59 @@ static int fillInUnixFile(
|
||||
pNew->pLock = NULL;
|
||||
pNew->pOpen = NULL;
|
||||
}
|
||||
|
||||
OSTRACE3("OPEN %-3d %s\n", h, zFilename);
|
||||
pNew->dirfd = -1;
|
||||
pNew->h = h;
|
||||
pNew->dirfd = dirfd;
|
||||
SET_THREADID(pNew);
|
||||
pNew = sqlite3_malloc( sizeof(unixFile) );
|
||||
if( pNew==0 ){
|
||||
close(h);
|
||||
enterMutex();
|
||||
releaseLockInfo(pNew->pLock);
|
||||
releaseOpenCnt(pNew->pOpen);
|
||||
leaveMutex();
|
||||
return SQLITE_NOMEM;
|
||||
}else{
|
||||
switch(lockingStyle) {
|
||||
case afpLockingStyle: {
|
||||
/* afp locking uses the file path so it needs to be included in
|
||||
** the afpLockingContext */
|
||||
int nFilename;
|
||||
pNew->pMethod = &sqlite3AFPLockingUnixIoMethod;
|
||||
pNew->lockingContext =
|
||||
sqlite3_malloc(sizeof(afpLockingContext));
|
||||
nFilename = strlen(zFilename)+1;
|
||||
((afpLockingContext *)pNew->lockingContext)->filePath =
|
||||
sqlite3_malloc(nFilename);
|
||||
memcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
|
||||
zFilename, nFilename);
|
||||
srandomdev();
|
||||
break;
|
||||
}
|
||||
case flockLockingStyle:
|
||||
/* flock locking doesn't need additional lockingContext information */
|
||||
pNew->pMethod = &sqlite3FlockLockingUnixIoMethod;
|
||||
break;
|
||||
case dotlockLockingStyle: {
|
||||
/* dotlock locking uses the file path so it needs to be included in
|
||||
** the dotlockLockingContext */
|
||||
int nFilename;
|
||||
pNew->pMethod = &sqlite3DotlockLockingUnixIoMethod;
|
||||
pNew->lockingContext = sqlite3_malloc(
|
||||
sizeof(dotlockLockingContext));
|
||||
nFilename = strlen(zFilename) + 6;
|
||||
((dotlockLockingContext *)pNew->lockingContext)->lockPath =
|
||||
sqlite3_malloc( nFilename );
|
||||
sqlite3_snprintf(nFilename,
|
||||
((dotlockLockingContext *)pNew->lockingContext)->lockPath,
|
||||
"%s.lock", zFilename);
|
||||
break;
|
||||
}
|
||||
case posixLockingStyle:
|
||||
/* posix locking doesn't need additional lockingContext information */
|
||||
pNew->pMethod = &sqlite3UnixIoMethod;
|
||||
break;
|
||||
case noLockingStyle:
|
||||
case unsupportedLockingStyle:
|
||||
default:
|
||||
pNew->pMethod = &sqlite3NolockLockingUnixIoMethod;
|
||||
|
||||
switch(lockingStyle) {
|
||||
case afpLockingStyle: {
|
||||
/* afp locking uses the file path so it needs to be included in
|
||||
** the afpLockingContext */
|
||||
int nFilename;
|
||||
pNew->pMethod = &sqlite3AFPLockingUnixIoMethod;
|
||||
pNew->lockingContext =
|
||||
sqlite3_malloc(sizeof(afpLockingContext));
|
||||
nFilename = strlen(zFilename)+1;
|
||||
((afpLockingContext *)pNew->lockingContext)->filePath =
|
||||
sqlite3_malloc(nFilename);
|
||||
memcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
|
||||
zFilename, nFilename);
|
||||
srandomdev();
|
||||
break;
|
||||
}
|
||||
OpenCounter(+1);
|
||||
return SQLITE_OK;
|
||||
case flockLockingStyle:
|
||||
/* flock locking doesn't need additional lockingContext information */
|
||||
pNew->pMethod = &sqlite3FlockLockingUnixIoMethod;
|
||||
break;
|
||||
case dotlockLockingStyle: {
|
||||
/* dotlock locking uses the file path so it needs to be included in
|
||||
** the dotlockLockingContext */
|
||||
int nFilename;
|
||||
pNew->pMethod = &sqlite3DotlockLockingUnixIoMethod;
|
||||
pNew->lockingContext = sqlite3_malloc(
|
||||
sizeof(dotlockLockingContext));
|
||||
nFilename = strlen(zFilename) + 6;
|
||||
((dotlockLockingContext *)pNew->lockingContext)->lockPath =
|
||||
sqlite3_malloc( nFilename );
|
||||
sqlite3_snprintf(nFilename,
|
||||
((dotlockLockingContext *)pNew->lockingContext)->lockPath,
|
||||
"%s.lock", zFilename);
|
||||
break;
|
||||
}
|
||||
case posixLockingStyle:
|
||||
/* posix locking doesn't need additional lockingContext information */
|
||||
pNew->pMethod = &sqlite3UnixIoMethod;
|
||||
break;
|
||||
case noLockingStyle:
|
||||
case unsupportedLockingStyle:
|
||||
default:
|
||||
pNew->pMethod = &sqlite3NolockLockingUnixIoMethod;
|
||||
}
|
||||
OpenCounter(+1);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#else /* SQLITE_ENABLE_LOCKING_STYLE */
|
||||
static int fillInUnixFile(
|
||||
|
Loading…
Reference in New Issue
Block a user