aboutsummaryrefslogtreecommitdiff
path: root/src/test_async.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2006-02-13 18:35:06 +0000
committerdrh <drh@noemail.net>2006-02-13 18:35:06 +0000
commit97bbdc0aa29697c96279126494da2eb22cf4bb01 (patch)
tree85621cd9742e2e8bb6799721f4043a2bc7fbb30f /src/test_async.c
parent89ea93121d010660a0d7da134082d5042d83770c (diff)
downloadsqlite-97bbdc0aa29697c96279126494da2eb22cf4bb01.tar.gz
sqlite-97bbdc0aa29697c96279126494da2eb22cf4bb01.zip
Fix a bug in the handling of sqlite3OsTruncate by the test_async.c demo.
Added trans.test to the suite of tests for asychronous I/O. (CVS 3091) FossilOrigin-Name: 5b16c43542194d6c736bf7aadaaa7f31ff12af31
Diffstat (limited to 'src/test_async.c')
-rw-r--r--src/test_async.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/test_async.c b/src/test_async.c
index fa8787ed5..a05ed2a0c 100644
--- a/src/test_async.c
+++ b/src/test_async.c
@@ -497,7 +497,8 @@ static int asyncRead(OsFile *id, void *obuf, int amt){
}
nRead = MIN(filesize - pFile->iOffset, amt);
if( nRead>0 ){
- rc = sqlite3OsRead(((AsyncFile *)id)->pBaseRead, obuf, nRead);
+ rc = sqlite3OsRead(pFile->pBaseRead, obuf, nRead);
+ TRACE(("READ %s %d bytes at %d\n", pFile->zName, nRead, pFile->iOffset));
}
}
@@ -517,6 +518,7 @@ static int asyncRead(OsFile *id, void *obuf, int amt){
if( nCopy>0 ){
memcpy(&((char *)obuf)[iBeginOut], &p->zBuf[iBeginIn], nCopy);
+ TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset));
}
}
}
@@ -623,7 +625,7 @@ static int asyncCheckReservedLock(OsFile *id){
rc = (int)sqlite3HashFind(&async.aLock, pFile->zName, pFile->nName);
pthread_mutex_unlock(&async.lockMutex);
TRACE(("CHECK-LOCK %d (%s)\n", rc, pFile->zName));
- return rc;
+ return rc>SHARED_LOCK;
}
/*
@@ -879,8 +881,6 @@ static void *asyncWriterThread(void *NotUsed){
}
}
if( p==0 ) break;
- TRACE(("PROCESSING %p (%s %s)\n", p, azOpcodeName[p->op],
- p->pFile ? p->pFile->zName : "-"));
/* Right now this thread is holding the mutex on the write-op queue.
** Variable 'p' points to the first entry in the write-op queue. In
@@ -925,6 +925,8 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_WRITE:
assert( pBase );
+ TRACE(("WRITE %s %d bytes at %d\n",
+ p->pFile->zName, p->nByte, p->iOffset));
rc = sqlite3OsSeek(pBase, p->iOffset);
if( rc==SQLITE_OK ){
rc = sqlite3OsWrite(pBase, (const void *)(p->zBuf), p->nByte);
@@ -933,15 +935,18 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_SYNC:
assert( pBase );
+ TRACE(("SYNC %s\n", p->pFile->zName));
rc = sqlite3OsSync(pBase, p->nByte);
break;
case ASYNC_TRUNCATE:
assert( pBase );
- rc = sqlite3OsTruncate(pBase, p->nByte);
+ TRACE(("TRUNCATE %s to %d bytes\n", p->pFile->zName, p->iOffset));
+ rc = sqlite3OsTruncate(pBase, p->iOffset);
break;
case ASYNC_CLOSE:
+ TRACE(("CLOSE %s\n", p->pFile->zName));
sqlite3OsClose(&p->pFile->pBaseRead);
sqlite3OsClose(&p->pFile->pBaseWrite);
sqlite3OsFree(p->pFile);
@@ -949,19 +954,23 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_OPENDIRECTORY:
assert( pBase );
+ TRACE(("OPENDIR %s\n", p->zBuf));
sqlite3OsOpenDirectory(pBase, p->zBuf);
break;
case ASYNC_SETFULLSYNC:
assert( pBase );
+ TRACE(("SETFULLSYNC %s %d\n", p->pFile->zName, p->nByte));
sqlite3OsSetFullSync(pBase, p->nByte);
break;
case ASYNC_DELETE:
+ TRACE(("DELETE %s\n", p->zBuf));
rc = xOrigDelete(p->zBuf);
break;
case ASYNC_SYNCDIRECTORY:
+ TRACE(("SYNCDIR %s\n", p->zBuf));
rc = xOrigSyncDirectory(p->zBuf);
break;
@@ -969,6 +978,7 @@ static void *asyncWriterThread(void *NotUsed){
AsyncFile *pFile = p->pFile;
int delFlag = ((p->iOffset)?1:0);
OsFile *pBase = 0;
+ TRACE(("OPEN %s delFlag=%d\n", p->zBuf, delFlag));
rc = xOrigOpenExclusive(p->zBuf, &pBase, delFlag);
assert( holdingMutex==0 );
pthread_mutex_lock(&async.queueMutex);
@@ -1175,7 +1185,7 @@ static int testAsyncWait(
pthread_mutex_lock(&async.writerMutex);
pthread_mutex_unlock(&async.writerMutex);
}else{
- TRACE(("NOTHING TO WAIT ON\n"));
+ TRACE(("NO-WAIT\n"));
}
return TCL_OK;
}