mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
In lsm (not SQLite), avoid opening the *-shm file before the database file is
locked. Otherwise, there is a race condition whereby a connection in another process process may unlink() it while it is still in use. FossilOrigin-Name: c8b8b9b573665c2b4d278bb679a48ac407374b8d860f0c3f4d50a303043464ad
This commit is contained in:
@ -340,9 +340,6 @@ static int doDbConnect(lsm_db *pDb){
|
||||
/* Obtain a pointer to the shared-memory header */
|
||||
assert( pDb->pShmhdr==0 );
|
||||
assert( pDb->bReadonly==0 );
|
||||
rc = lsmShmCacheChunks(pDb, 1);
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
pDb->pShmhdr = (ShmHeader *)pDb->apShm[0];
|
||||
|
||||
/* Block for an exclusive lock on DMS1. This lock serializes all calls
|
||||
** to doDbConnect() and doDbDisconnect() across all processes. */
|
||||
@ -353,10 +350,11 @@ static int doDbConnect(lsm_db *pDb){
|
||||
nUs = nUs * 2;
|
||||
if( nUs>nUsMax ) nUs = nUsMax;
|
||||
}
|
||||
if( rc!=LSM_OK ){
|
||||
pDb->pShmhdr = 0;
|
||||
return rc;
|
||||
if( rc==LSM_OK ){
|
||||
rc = lsmShmCacheChunks(pDb, 1);
|
||||
}
|
||||
if( rc!=LSM_OK ) return rc;
|
||||
pDb->pShmhdr = (ShmHeader *)pDb->apShm[0];
|
||||
|
||||
/* Try an exclusive lock on DMS2/DMS3. If successful, this is the first
|
||||
** and only connection to the database. In this case initialize the
|
||||
|
Reference in New Issue
Block a user