diff --git a/manifest b/manifest index f1ca3e28a6..7f2143caf9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sjrnlmode2.test\sso\sthat\sit\sworks\son\ssystems\swhere\sUNDELETABLE_WHEN_OPEN\sis\sdefined. -D 2010-06-21T05:40:49 +C Merge\slatest\strunk\schange. +D 2010-06-21T06:00:16 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -154,7 +154,7 @@ F src/os.c 9c4a2f82a50306a33907678ec0187b6ad1486bfe F src/os.h d7775504a51e6e0d40315aa427b3e229ff9ff9ca F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19 -F src/os_unix.c 2555f00c4c777539c33a2ef0e65f71cff08a6fa0 +F src/os_unix.c 5231a75a3799872b1250bc70c0e6a1a5960bc865 F src/os_win.c 73608839342de32280cb378d3c2fc85a5dd80bd2 F src/pager.c 6ebb43239ad4ae2c0b0720bbd88a6a84a301bc8a F src/pager.h ca1f23c0cf137ac26f8908df2427c8b308361efd @@ -824,7 +824,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3e76a9f2c041a6d36614f540bb89588703d85925 -R b870a455574cea6100e536dd46b8d81b +P 59be370e52ec814c45efa6cbac45b6df94661b54 822a0283c6bc1c75001f3d1c528a4ff89c6b039c +R cd73ab3d3f6400b82e1db5686eff6200 U dan -Z d0b6213f5feedc09ae1f6676dae25d67 +Z 0c29ece94fc927539688ff52cbe59deb diff --git a/manifest.uuid b/manifest.uuid index e802654324..6b35f2cebc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59be370e52ec814c45efa6cbac45b6df94661b54 \ No newline at end of file +f6d26e07b70965e332b1589804ca938593a5f432 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 9966ed6097..77aafccce9 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3274,19 +3274,21 @@ static void unixShmPurge(unixFile *pFd){ } } -/* Forward reference */ -static const char *unixTempFileDir(int); - /* -** Open a shared-memory area. This particular implementation uses -** mmapped files. +** Open a shared-memory area associated with open database file fd. +** 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. +** The file used to implement shared-memory is in the same directory +** as the open database file and has the same name as the open database +** file with the "-shm" suffix added. For example, if the database file +** is "/home/user1/config.db" then the file that is created and mmapped +** for shared memory will be called "/home/user1/config.db-shm". We +** experimented with using files in /dev/tmp or an some other tmpfs mount. +** But if a file in a different directory from the database file is used, +** then differing access permissions or a chroot() might cause two different +** processes on the same database to end up using different files for +** shared memory - meaning that their memory would not really be shared - +** resulting in database corruption. ** ** 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 @@ -3300,8 +3302,8 @@ static int unixShmOpen( int rc; /* Result code */ struct unixFile *pDbFd; /* Underlying database file */ unixInodeInfo *pInode; /* The inode of fd */ - const char *zTempDir; /* Directory for temporary files */ - int nTempDir; /* Size of the zTempDir string */ + char *zShmFilename; /* Name of the file used for SHM */ + int nShmFilename; /* Size of the SHM filename in bytes */ /* Allocate space for the new sqlite3_shm object. */ @@ -3318,23 +3320,15 @@ static int unixShmOpen( pInode = pDbFd->pInode; pShmNode = pInode->pShmNode; if( pShmNode==0 ){ - zTempDir = unixTempFileDir(1); - if( zTempDir==0 ){ - unixLeaveMutex(); - sqlite3_free(p); - return SQLITE_CANTOPEN_NOTEMPDIR; - } - nTempDir = strlen(zTempDir); - pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nTempDir + 50 ); + nShmFilename = 5 + (int)strlen(pDbFd->zPath); + pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename ); if( pShmNode==0 ){ rc = SQLITE_NOMEM; goto shm_open_err; } memset(pShmNode, 0, sizeof(*pShmNode)); - pShmNode->zFilename = (char*)&pShmNode[1]; - sqlite3_snprintf(nTempDir+50, pShmNode->zFilename, - "%s/sqlite-wi-%x-%x", zTempDir, - (u32)pInode->fileId.dev, (u32)pInode->fileId.ino); + zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1]; + sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", pDbFd->zPath); pShmNode->h = -1; pDbFd->pInode->pShmNode = pShmNode; pShmNode->pInode = pDbFd->pInode; @@ -3344,7 +3338,7 @@ static int unixShmOpen( goto shm_open_err; } - pShmNode->h = open(pShmNode->zFilename, O_RDWR|O_CREAT, 0664); + pShmNode->h = open(zShmFilename, O_RDWR|O_CREAT, 0664); if( pShmNode->h<0 ){ rc = SQLITE_CANTOPEN_BKPT; goto shm_open_err; @@ -4157,7 +4151,7 @@ static int openDirectory(const char *zFilename, int *pFd){ ** Return the name of a directory in which to put temporary files. ** If no suitable temporary file directory can be found, return NULL. */ -static const char *unixTempFileDir(int allowShm){ +static const char *unixTempFileDir(void){ static const char *azDirs[] = { 0, 0, @@ -4172,19 +4166,11 @@ static const char *unixTempFileDir(int allowShm){ azDirs[0] = sqlite3_temp_directory; if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); - - if( allowShm ){ - zDir = "/dev/shm"; - i = 2; /* Skip the app-defined temp locations for shared-memory */ - }else{ - zDir = azDirs[0]; - i = 1; - } - for(; i