Fix a bad interaction between "proxy-locking" and [http://www.sqlite.org/src/vdiff/aa6acfa8caa2ef59b4c16dfe42c4b5644da96905|aa6acfa8ca].
FossilOrigin-Name: 2a5c9e1dbf7f5f4b2081c964450a9305a4516f5b
This commit is contained in:
parent
6aa657f76b
commit
15edd587fd
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\ssome\serrors\sin\s[http://www.sqlite.org/src/vdiff/aa6acfa8caa2ef59b4c16dfe42c4b5644da96905|aa6acfa8ca].
|
||||
D 2009-08-24T18:57:58
|
||||
C Fix\sa\sbad\sinteraction\sbetween\s"proxy-locking"\sand\s[http://www.sqlite.org/src/vdiff/aa6acfa8caa2ef59b4c16dfe42c4b5644da96905|aa6acfa8ca].
|
||||
D 2009-08-25T05:57:48
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 73ddeec9dd10b85876c5c2ce1fdce627e1dcc7f8
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -144,7 +144,7 @@ F src/os.c 9fea283e336ee31caa4654d6cb05a129a1c42d2f
|
||||
F src/os.h 00a1334a4eecee7f7bef79ac606b88d325119f21
|
||||
F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
|
||||
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
||||
F src/os_unix.c 5fc8443b16d64faf3db374f6dda959cfe3202a03
|
||||
F src/os_unix.c 96e2e409df8851a31fdb2d7430ad73fea7b0a104
|
||||
F src/os_win.c 58bb163f327e79726dd119344d908e4d98483c3f
|
||||
F src/pager.c a47be286477ed6c7b9a342dd53d4e4043f29d8c2
|
||||
F src/pager.h 11852d044c86cf5a9d6e34171fb0c4fcf1f6265f
|
||||
@ -747,7 +747,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
|
||||
P f7eb1efc37d0658d66b3b86d5afd5419d22bfe92
|
||||
R 83c4813ff710350c0fba94b0a5e87768
|
||||
P 82d1934a428a34c292a612fb67bbcea262990e0f
|
||||
R d7c1a30840419801458f3ecc7f6aa251
|
||||
U dan
|
||||
Z 0b89a0ea45e445bcb467bd70aa77089d
|
||||
Z 6b17644948440e13ab90b6fbc376f045
|
||||
|
@ -1 +1 @@
|
||||
82d1934a428a34c292a612fb67bbcea262990e0f
|
||||
2a5c9e1dbf7f5f4b2081c964450a9305a4516f5b
|
@ -3902,7 +3902,7 @@ static int unixOpen(
|
||||
noLock = eType!=SQLITE_OPEN_MAIN_DB;
|
||||
|
||||
#if SQLITE_PREFER_PROXY_LOCKING
|
||||
if( zPath!=NULL && !noLock ){
|
||||
if( zPath!=NULL && !noLock && pVfs->xOpen ){
|
||||
char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING");
|
||||
int useProxy = 0;
|
||||
|
||||
@ -4617,33 +4617,43 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
|
||||
** but also for freeing the memory associated with the file descriptor.
|
||||
*/
|
||||
static int proxyCreateUnixFile(const char *path, unixFile **ppFile) {
|
||||
int fd;
|
||||
int dirfd = -1;
|
||||
unixFile *pNew;
|
||||
int flags = SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3_vfs dummyVfs;
|
||||
|
||||
fd = open(path, O_RDWR | O_CREAT, SQLITE_DEFAULT_FILE_PERMISSIONS);
|
||||
if( fd<0 ){
|
||||
return SQLITE_CANTOPEN;
|
||||
}
|
||||
|
||||
pNew = (unixFile *)sqlite3_malloc(sizeof(unixFile));
|
||||
if( pNew==NULL ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto end_create_proxy;
|
||||
if( !pNew ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
memset(pNew, 0, sizeof(unixFile));
|
||||
|
||||
/* Call unixOpen() to open the proxy file. The flags passed to unixOpen()
|
||||
** suggest that the file being opened is a "main database". This is
|
||||
** necessary as other file types do not necessarily support locking. It
|
||||
** is better to use unixOpen() instead of opening the file directly with
|
||||
** open(), as unixOpen() sets up the various mechanisms required to
|
||||
** make sure a call to close() does not cause the system to discard
|
||||
** POSIX locks prematurely.
|
||||
**
|
||||
** It is important that the xOpen member of the VFS object passed to
|
||||
** unixOpen() is NULL. This tells unixOpen() may try to open a proxy-file
|
||||
** for the proxy-file (creating a potential infinite loop).
|
||||
*/
|
||||
dummyVfs.pAppData = (void*)&autolockIoFinder;
|
||||
rc = fillInUnixFile(&dummyVfs, fd, dirfd, (sqlite3_file*)pNew, path, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
*ppFile = pNew;
|
||||
return SQLITE_OK;
|
||||
dummyVfs.xOpen = 0;
|
||||
rc = unixOpen(&dummyVfs, path, (sqlite3_file *)pNew, flags, &flags);
|
||||
if( rc==SQLITE_OK && (flags&SQLITE_OPEN_READONLY) ){
|
||||
pNew->pMethod->xClose((sqlite3_file *)pNew);
|
||||
rc = SQLITE_CANTOPEN;
|
||||
}
|
||||
end_create_proxy:
|
||||
close(fd); /* silently leak fd if error, we're already in error */
|
||||
sqlite3_free(pNew);
|
||||
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3_free(pNew);
|
||||
pNew = 0;
|
||||
}
|
||||
|
||||
*ppFile = pNew;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user