-C Fix\soverlapping\sread\slogic\sin\sthe\stest_async.c\sdemonstration.\s(CVS\s3086)
-D 2006-02-13T13:30:19
+C I/O\serrors\sshut\sdown\sall\sprocessing\son\sthe\ssame\sfile\sin\stest_async.c.\s(CVS\s3087)
+D 2006-02-13T13:50:56
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 60a02961ceb7b3edc25f5dc5c1ac2556622a76de
F src/test7.c d28d3e62f9594923648fc6a8fb030eba36564ba1
-F src/test_async.c 818c346094f164a5f6d1051c5df4849f548a832c
+F src/test_async.c 3788835109389314abd9281b42bdb3a39e626016
F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
F src/test_server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/tokenize.c 382b3bb0ca26eb9153b5d20b246ef512a114a24f
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 904ffa4dfb60e00b01db17049de2f4934537f3d8
-R c15c7a4a0ef3b7c380f375710e72f985
+P ad25127b067b3135694ddb0de552aad981640669
+R c172fd59b56c5fed4fe5f809faeffff3
U drh
-Z 3b25fcdac403270a231a8a67cd00fbda
+Z 077affc5334060506b2ff1fb3322bebe
};
/* Possible values of AsyncWrite.op */
+#define ASYNC_NOOP 0
#define ASYNC_WRITE 1
#define ASYNC_SYNC 2
#define ASYNC_TRUNCATE 3
*/
struct AsyncFile {
IoMethod *pMethod; /* Must be first */
- i64 iOffset; /* Current seek() offset in file */
+ int ioError; /* Value of any asychronous error we have seen */ i64 iOffset; /* Current seek() offset in file */
OsFile *pBaseRead; /* Read handle to the underlying Os file */
OsFile *pBaseWrite; /* Write handle to the underlying Os file */
};
int nByte,
const char *zByte
){
- AsyncWrite *p = sqlite3OsMalloc(sizeof(AsyncWrite) + (zByte?nByte:0));
+ AsyncWrite *p;
+ if( pFile && pFile->ioError!=SQLITE_OK ){
+ return pFile->ioError;
+ }
+ p = sqlite3OsMalloc(sizeof(AsyncWrite) + (zByte?nByte:0));
if( !p ){
return SQLITE_NOMEM;
}
int nRead;
AsyncFile *pFile = (AsyncFile *)id;
+ /* If an I/O error has previously occurred on this file, then all
+ ** subsequent operations fail.
+ */
+ if( pFile->ioError!=SQLITE_OK ){
+ return pFile->ioError;
+ }
+
/* Grab the write queue mutex for the duration of the call */
pthread_mutex_lock(&async.queueMutex);
p->pMethod = &iomethod;
p->pBaseRead = pBaseRead;
p->pBaseWrite = pBaseWrite;
+ p->ioError = SQLITE_OK;
*pFile = (OsFile *)p;
return SQLITE_OK;
*/
if( p->pFile ){
pBase = p->pFile->pBaseWrite;
+ if( p->pFile->ioError!=SQLITE_OK && p->op!=ASYNC_CLOSE ){
+ p->op = ASYNC_NOOP;
+ }
if(
p->op==ASYNC_CLOSE ||
p->op==ASYNC_OPENEXCLUSIVE ||
}
switch( p->op ){
+ case ASYNC_NOOP:
+ break;
+
case ASYNC_WRITE:
assert( pBase );
rc = sqlite3OsSeek(pBase, p->iOffset);
default: assert(!"Illegal value for AsyncWrite.op");
}
+ /* If an error happens, store the error code in the pFile.ioError
+ ** field. This will prevent any future operations on that file,
+ ** other than closing it.
+ **
+ ** We cannot report the error back to the connection that requested
+ ** the I/O since the error happened asynchronously. The connection has
+ ** already moved on. There really is nobody to report the error to.
+ */
+ if( rc!=SQLITE_OK ){
+ p->pFile->ioError = rc;
+ rc = SQLITE_OK;
+ }
+
/* If we didn't hang on to the mutex during the IO op, obtain it now
** so that the AsyncWrite structure can be safely removed from the
** global write-op queue.
holdingMutex = 1;
}
TRACE("UNLINK %p\n", p);
- if( rc==SQLITE_OK ){
- if( p==async.pQueueLast ){
- async.pQueueLast = 0;
- }
- async.pQueueFirst = p->pNext;
+ if( p==async.pQueueLast ){
+ async.pQueueLast = 0;
}
+ async.pQueueFirst = p->pNext;
sqlite3OsFree(p);
assert( holdingMutex );