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

When a VFS.xOpen fails, make sure the pMethods pointer is zeroed on the

sqlite3_file object so that subsequent xClose() operations against that
same file handler are no-ops.  Bug in the test_async.c module only - not
in the core library.  Ticket #3744. (CVS 6384)

FossilOrigin-Name: c32b454118f4b0cc615edb9b35f749db45f6b36d
This commit is contained in:
drh
2009-03-25 14:24:41 +00:00
parent 892404323f
commit 072db2fb13
4 changed files with 21 additions and 15 deletions

View File

@@ -10,7 +10,7 @@
**
*************************************************************************
**
** $Id: test_async.c,v 1.50 2009/03/24 16:27:09 drh Exp $
** $Id: test_async.c,v 1.51 2009/03/25 14:24:42 drh Exp $
**
** This file contains an example implementation of an asynchronous IO
** backend for SQLite.
@@ -419,7 +419,7 @@ struct AsyncFileData {
sqlite3_file *pBaseWrite; /* Write handle to the underlying Os file */
AsyncFileLock lock; /* Lock state for this handle */
AsyncLock *pLock; /* AsyncLock object for this file system entry */
AsyncWrite close;
AsyncWrite closeOp; /* Preallocated close operation */
};
/*
@@ -701,7 +701,7 @@ static int asyncClose(sqlite3_file *pFile){
p->lock.eLock = 0;
pthread_mutex_unlock(&async.lockMutex);
addAsyncWrite(&p->close);
addAsyncWrite(&p->closeOp);
return SQLITE_OK;
}
@@ -1097,8 +1097,8 @@ static int asyncOpen(
pData->pBaseRead = (sqlite3_file*)z;
z += pVfs->szOsFile;
pData->pBaseWrite = (sqlite3_file*)z;
pData->close.pFileData = pData;
pData->close.op = ASYNC_CLOSE;
pData->closeOp.pFileData = pData;
pData->closeOp.op = ASYNC_CLOSE;
if( zName ){
z += pVfs->szOsFile;
@@ -1186,6 +1186,9 @@ static int asyncOpen(
sqlite3_free(pData);
}
}
if( rc!=SQLITE_OK ){
p->pMethod = 0;
}
return rc;
}