1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Fix an incompatibility between the test_async.c backend and change (6390). (CVS 6391)

FossilOrigin-Name: 6762625d29d5e0053afdad033fe54e2d9121046a
This commit is contained in:
danielk1977
2009-03-27 09:10:12 +00:00
parent ee8b799d47
commit 62e5a81a5a
4 changed files with 41 additions and 15 deletions

View File

@@ -10,7 +10,7 @@
**
*************************************************************************
**
** $Id: test_async.c,v 1.52 2009/03/25 16:51:43 drh Exp $
** $Id: test_async.c,v 1.53 2009/03/27 09:10:12 danielk1977 Exp $
**
** This file contains an example implementation of an asynchronous IO
** backend for SQLite.
@@ -1041,6 +1041,25 @@ static int unlinkAsyncFile(AsyncFileData *pData){
return rc;
}
/*
** The parameter passed to this function is a copy of a 'flags' parameter
** passed to this modules xOpen() method. This function returns true
** if the file should be opened asynchronously, or false if it should
** be opened immediately.
**
** If the file is to be opened asynchronously, then asyncOpen() will add
** an entry to the event queue and the file will not actually be opened
** until the event is processed. Otherwise, the file is opened directly
** by the caller.
*/
static int doAsynchronousOpen(int flags){
return (flags&SQLITE_OPEN_CREATE) && (
(flags&SQLITE_OPEN_MAIN_JOURNAL) ||
(flags&SQLITE_OPEN_TEMP_JOURNAL) ||
(flags&SQLITE_OPEN_DELETEONCLOSE)
);
}
/*
** Open a file.
*/
@@ -1075,7 +1094,7 @@ static int asyncOpen(
AsyncFileData *pData;
AsyncLock *pLock = 0;
char *z;
int isExclusive = (flags&SQLITE_OPEN_EXCLUSIVE);
int isAsyncOpen = doAsynchronousOpen(flags);
/* If zName is NULL, then the upper layer is requesting an anonymous file */
if( zName ){
@@ -1107,11 +1126,15 @@ static int asyncOpen(
memcpy(pData->zName, zName, nName);
}
if( !isExclusive ){
rc = pVfs->xOpen(pVfs, zName, pData->pBaseRead, flags, pOutFlags);
if( rc==SQLITE_OK && ((*pOutFlags)&SQLITE_OPEN_READWRITE) ){
if( !isAsyncOpen ){
int flagsout;
rc = pVfs->xOpen(pVfs, zName, pData->pBaseRead, flags, &flagsout);
if( rc==SQLITE_OK && (flagsout&SQLITE_OPEN_READWRITE) ){
rc = pVfs->xOpen(pVfs, zName, pData->pBaseWrite, flags, 0);
}
if( pOutFlags ){
*pOutFlags = flagsout;
}
}
pthread_mutex_lock(&async.lockMutex);
@@ -1175,7 +1198,7 @@ static int asyncOpen(
pData->pLock = pLock;
}
if( rc==SQLITE_OK && isExclusive ){
if( rc==SQLITE_OK && isAsyncOpen ){
rc = addNewAsyncWrite(pData, ASYNC_OPENEXCLUSIVE, (sqlite3_int64)flags,0,0);
if( rc==SQLITE_OK ){
if( pOutFlags ) *pOutFlags = flags;