-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-C Remove\sthe\sxShmPush\sand\sxShmPull\smethods\sfrom\sthe\sVFS.
-D 2010-05-01T18:23:09
+C Change\sthe\sSHM\sinterface\sso\sthat\sit\sdoes\snot\stake\sthe\sname\sof\sthe\sshared\nobject\sbut\srather\sthe\sname\sof\sthe\sWAL\sfile\sand\sderives\sits\sown\sname\sfrom\nthat.\s\sRemove\sthe\sxShmDelete\smethod\sfrom\sthe\sVFS\sand\sreplace\sit\swith\sa\ndelete\sflag\son\sxShmClose.
+D 2010-05-01T20:17:31
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/os.h 534b082c3cb349ad05fa6fa0b06087e022af282c
F src/os_common.h 0d6ee583b6ee3185eb9d951f890c6dd03021a08d
F src/os_os2.c 8ad77a418630d7dee91d1bb04f79c2096301d3a0
-F src/os_unix.c d003631afe10f2cbbf0f4eb4ea72122e0522bbc7
+F src/os_unix.c 5c821e4eb04093102d901c22f40341bc1d30aef0
F src/os_win.c a8fc01d8483be472e495793c01064fd87e56a5c1
F src/pager.c e9c7fe979b32a3c5bf4216d8fbe1cf8beff8a1b8
F src/pager.h 934b598583a9d936bb13c37d62a2fe68ac48781c
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c c03d8a0565febcde8c6a12c5d77d065fddae889b
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
-F src/sqlite.h.in fdf272c7bb095633d3f5f916cf7384c4faa505e5
+F src/sqlite.h.in 50df638fd31ae342d280582af8fc9d232b588dfe
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
F src/sqliteInt.h 3eb613c8ba7f5159be0acf3fc148d41ec49add86
F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6
F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2
F src/test_config.c 6210f501d358bde619ae761f06f123529c6ba24f
F src/test_demovfs.c da81a5f7785bb352bda7911c332a983ec4f17f27
-F src/test_devsym.c c05024cd179603181cde66d0ff83ce81e146f6de
+F src/test_devsym.c 84b80966ee2aa72fdd0b42eaa90406478f390b03
F src/test_func.c 13b582345fb1185a93e46c53310fae8547dcce20
F src/test_hexio.c 1237f000ec7a491009b1233f5c626ea71bce1ea2
F src/test_init.c 5d624ffd0409d424cf9adbfe1f056b200270077c
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
-F src/wal.c 4a9b7fb028059992dfe51d23f0ced78064459c84
+F src/wal.c dadd533e0103883f72bf541eaf1ef34adb4e3c99
F src/wal.h d6d4a6809151e30bed5b01dd05cf27858f5a7bc8
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 6af2dca75b8139134ea394c1d71aefc6523f02e9
-R 9c99ea4eb3e50a401439b06a40f3fab6
+P 69e07fdbde5054593de948b76dfac157cf5d4058
+R c9705329895ad0e28623e29f2274d0f1
U drh
-Z cd290cf28dda9654fd31e687004b2a61
+Z 6445a2aee9bd8de55a45628ec7b23c47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
-iD8DBQFL3HGQoxKgR168RlERAlVgAJ49vhn/g4iu17//PQ8uRvfsTGbduwCfWA3t
-4QBB9V7wP5NNoershsjx378=
-=2IGM
+iD8DBQFL3IxeoxKgR168RlERAtmWAJ9fbAccfEA031KC3xWSzcIzuGnUqQCfVHJO
+hXR2b742paRdI5uwLVma/eQ=
+=uRJQ
-----END PGP SIGNATURE-----
-69e07fdbde5054593de948b76dfac157cf5d4058
\ No newline at end of file
+94dea5f9c11a68564220cec76ac3fae2ba90e907
\ No newline at end of file
}
/*
-** Open a shared-memory area. This implementation uses mmapped files.
+** Open a shared-memory area. This particular implementation uses
+** mmapped files.
+**
+** zName is a filename used to identify the shared-memory area. The
+** implementation does not (and perhaps should not) use this name
+** directly, but rather use it as a template for finding an appropriate
+** name for the shared-memory storage. In this implementation, the
+** string "-index" is appended to zName and used as the name of the
+** mmapped file.
**
** When opening a new shared-memory file, if no other instances of that
** file are currently open, in this process or in other processes, then
*/
static int unixShmOpen(
sqlite3_vfs *pVfs, /* The VFS */
- const char *zName, /* Name of file to mmap */
+ const char *zName, /* Base name of file to mmap */
sqlite3_shm **pShm /* Write the unixShm object created here */
){
struct unixShm *p = 0; /* The connection to be opened */
struct unixShmFile *pFile = 0; /* The underlying mmapped file */
int rc; /* Result code */
struct unixFileId fid; /* Unix file identifier */
+ struct unixShmFile *pNew; /* Newly allocated pFile */
struct stat sStat; /* Result from stat() an fstat() */
+ int nName; /* Size of zName in bytes */
- /* Allocate space for the new sqlite3_shm object */
+ /* Allocate space for the new sqlite3_shm object. Also speculatively
+ ** allocate space for a new unixShmFile and filename.
+ */
p = sqlite3_malloc( sizeof(*p) );
if( p==0 ) return SQLITE_NOMEM;
memset(p, 0, sizeof(*p));
+ nName = strlen(zName);
+ pNew = sqlite3_malloc( sizeof(*pFile) + nName + 10 );
+ if( pNew==0 ){
+ rc = SQLITE_NOMEM;
+ goto shm_open_err;
+ }
+ memset(pNew, 0, sizeof(*pNew));
+ pNew->zFilename = (char*)&pNew[1];
+ sqlite3_snprintf(nName+10, pNew->zFilename, "%s-index", zName);
/* Look to see if there is an existing unixShmFile that can be used.
** If no matching unixShmFile currently exists, create a new one.
*/
unixEnterMutex();
- rc = stat(zName, &sStat);
+ rc = stat(pNew->zFilename, &sStat);
if( rc==0 ){
memset(&fid, 0, sizeof(fid));
fid.dev = sStat.st_dev;
if( memcmp(&pFile->fid, &fid, sizeof(fid))==0 ) break;
}
}
- if( pFile==0 ){
- int nName = strlen(zName);
- pFile = sqlite3_malloc( sizeof(*pFile) + nName + 1 );
- if( pFile==0 ){
- rc = SQLITE_NOMEM;
- goto shm_open_err;
- }
- memset(pFile, 0, sizeof(*pFile));
- pFile->zFilename = (char*)&pFile[1];
- memcpy(pFile->zFilename, zName, nName+1);
+ if( pFile ){
+ sqlite3_free(pNew);
+ }else{
+ pFile = pNew;
+ pNew = 0;
pFile->h = -1;
pFile->pNext = unixShmFileList;
unixShmFileList = pFile;
goto shm_open_err;
}
- pFile->h = open(zName, O_RDWR|O_CREAT, 0664);
+ pFile->h = open(pFile->zFilename, O_RDWR|O_CREAT, 0664);
if( pFile->h<0 ){
rc = SQLITE_CANTOPEN_BKPT;
goto shm_open_err;
unixShmPurge();
sqlite3_free(p);
sqlite3_free(pFile);
+ sqlite3_free(pNew);
*pShm = 0;
unixLeaveMutex();
return rc;
}
/*
-** Close a connectioon to shared-memory.
+** Close a connection to shared-memory. Delete the underlying
+** storage if deleteFlag is true.
*/
-static int unixShmClose(sqlite3_shm *pSharedMem){
+static int unixShmClose(sqlite3_shm *pSharedMem, int deleteFlag){
unixShm *p; /* The connection to be closed */
unixShmFile *pFile; /* The underlying shared-memory file */
unixShm **pp; /* For looping over sibling connections */
assert( pFile->nRef>0 );
pFile->nRef--;
if( pFile->nRef==0 ){
+ if( deleteFlag ) unlink(pFile->zFilename);
unixShmPurge();
}
unixLeaveMutex();
return rc;
}
-/*
-** Delete a shared-memory segment from the system.
-*/
-static int unixShmDelete(sqlite3_vfs *pVfs, const char *zName){
- return pVfs->xDelete(pVfs, zName, 0);
-}
-
#else
# define unixShmOpen 0
# define unixShmSize 0
# define unixShmRelease 0
# define unixShmLock 0
# define unixShmClose 0
-# define unixShmDelete 0
#endif /* #ifndef SQLITE_OMIT_WAL */
/*
unixShmRelease, /* xShmRelease */ \
unixShmLock, /* xShmLock */ \
unixShmClose, /* xShmClose */ \
- unixShmDelete, /* xShmDelete */ \
0, /* xRename */ \
0, /* xCurrentTimeInt64 */ \
}
int (*xShmGet)(sqlite3_shm*, int reqMapSize, int *pMapSize, void**);
int (*xShmRelease)(sqlite3_shm*);
int (*xShmLock)(sqlite3_shm*, int desiredLock, int *gotLock);
- int (*xShmClose)(sqlite3_shm*);
- int (*xShmDelete)(sqlite3_vfs*, const char *zName);
+ int (*xShmClose)(sqlite3_shm*, int deleteFlag);
int (*xRename)(sqlite3_vfs*, const char *zOld, const char *zNew, int dirSync);
int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
/*
static int devsymShmGet(sqlite3_shm *, int , int *, void **);
static int devsymShmRelease(sqlite3_shm *);
static int devsymShmLock(sqlite3_shm *, int , int *);
-static int devsymShmClose(sqlite3_shm *);
-static int devsymShmDelete(sqlite3_vfs *, const char *);
+static int devsymShmClose(sqlite3_shm *, int);
static sqlite3_vfs devsym_vfs = {
2, /* iVersion */
0,
devsymShmLock,
devsymShmClose,
- devsymShmDelete,
0,
0,
};
static int devsymShmLock(sqlite3_shm *p, int desiredLock, int *gotLock){
return g.pVfs->xShmLock(p, desiredLock, gotLock);
}
-static int devsymShmClose(sqlite3_shm *p){
- return g.pVfs->xShmClose(p);
-}
-static int devsymShmDelete(sqlite3_vfs *pVfs, const char *zName){
- return g.pVfs->xShmDelete(g.pVfs, zName);
+static int devsymShmClose(sqlite3_shm *p, int deleteFlag){
+ return g.pVfs->xShmClose(p, deleteFlag);
}
/*
devsym_vfs.xShmRelease = (g.pVfs->xShmRelease ? devsymShmRelease : 0);
devsym_vfs.xShmLock = (g.pVfs->xShmLock ? devsymShmLock : 0);
devsym_vfs.xShmClose = (g.pVfs->xShmClose ? devsymShmClose : 0);
- devsym_vfs.xShmDelete = (g.pVfs->xShmDelete ? devsymShmDelete : 0);
sqlite3_vfs_register(&devsym_vfs, 0);
}
if( iDeviceChar>=0 ){
u8 lockState; /* SQLITE_SHM_xxxx constant showing lock state */
u8 readerType; /* SQLITE_SHM_READ or SQLITE_SHM_READ_FULL */
WalIndexHdr hdr; /* Wal-index for current snapshot */
+ char *zName; /* Name of underlying storage */
};
/* Allocate an instance of struct Wal to return. */
*ppWal = 0;
nWal = strlen(zDb);
- pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile + nWal+11);
+ pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile + nWal+5);
if( !pRet ) goto wal_open_out;
pRet->pVfs = pVfs;
pRet->pFd = (sqlite3_file *)&pRet[1];
- zWal = pVfs->szOsFile + (char*)pRet->pFd;
- sqlite3_snprintf(nWal+11, zWal, "%s-wal-index", zDb);
+ pRet->zName = zWal = pVfs->szOsFile + (char*)pRet->pFd;
+ sqlite3_snprintf(nWal+5, zWal, "%s-wal", zDb);
rc = pVfs->xShmOpen(pVfs, zWal, &pRet->pWIndex);
if( rc ) goto wal_open_out;
/* Open file handle on the write-ahead log file. */
- zWal[nWal+4] = 0;
flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_JOURNAL);
rc = sqlite3OsOpen(pVfs, zWal, pRet->pFd, flags, &flags);
wal_open_out:
if( rc!=SQLITE_OK ){
if( pRet ){
- pVfs->xShmClose(pRet->pWIndex);
+ pVfs->xShmClose(pRet->pWIndex, 0);
sqlite3OsClose(pRet->pFd);
sqlite3_free(pRet);
}
walIndexUnmap(pWal);
}
- pWal->pVfs->xShmClose(pWal->pWIndex);
+ pWal->pVfs->xShmClose(pWal->pWIndex, isDelete);
sqlite3OsClose(pWal->pFd);
if( isDelete ){
- int nWal;
- char *zWal = &((char *)pWal->pFd)[pWal->pVfs->szOsFile];
- sqlite3OsDelete(pWal->pVfs, zWal, 0);
- nWal = sqlite3Strlen30(zWal);
- memcpy(&zWal[nWal], "-index", 7);
- pWal->pVfs->xShmDelete(pWal->pVfs, zWal);
+ sqlite3OsDelete(pWal->pVfs, pWal->zName, 0);
}
sqlite3_free(pWal);
}