/ Check-in [239e53b4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bug in test_async.c version of OsFileSize(). (CVS 3095)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 239e53b4f29b4faf2dbdc2aebd2332ad25b14286
User & Date: danielk1977 2006-02-14 13:48:34
Context
2006-02-14
14:02
Account for a malloc failure in the asynchronous writer thread in test_async.c (CVS 3096) check-in: 2f2a8a69 user: danielk1977 tags: trunk
13:48
Fix bug in test_async.c version of OsFileSize(). (CVS 3095) check-in: 239e53b4 user: danielk1977 tags: trunk
13:25
Add simple io error tests for test_async.c. (CVS 3094) check-in: 528dfb71 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test_async.c.

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
  if( async.pQueueLast ){
    assert( async.pQueueFirst );
    async.pQueueLast->pNext = pWrite;
  }else{
    async.pQueueFirst = pWrite;
  }
  async.pQueueLast = pWrite;
  TRACE(("PUSH %p (%s %s)\n", pWrite, azOpcodeName[pWrite->op],
         pWrite->pFile ? pWrite->pFile->zName : "-"));

  if( pWrite->op==ASYNC_CLOSE ){
    async.nFile--;
    if( async.nFile==0 ){
      async.ioError = SQLITE_OK;
    }
  }
................................................................................
    for(p=async.pQueueFirst; p; p = p->pNext){
      if( p->pFile==(AsyncFile *)id ){
        switch( p->op ){
          case ASYNC_WRITE:
            s = MAX(p->iOffset + (i64)(p->nByte), s);
            break;
          case ASYNC_TRUNCATE:
            s = MIN(s, p->nByte);
            break;
        }
      }
    }
    *pSize = s;
  }
  pthread_mutex_unlock(&async.queueMutex);







|
|







 







|







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
  if( async.pQueueLast ){
    assert( async.pQueueFirst );
    async.pQueueLast->pNext = pWrite;
  }else{
    async.pQueueFirst = pWrite;
  }
  async.pQueueLast = pWrite;
  TRACE(("PUSH %p (%s %s %d)\n", pWrite, azOpcodeName[pWrite->op],
         pWrite->pFile ? pWrite->pFile->zName : "-", pWrite->iOffset));

  if( pWrite->op==ASYNC_CLOSE ){
    async.nFile--;
    if( async.nFile==0 ){
      async.ioError = SQLITE_OK;
    }
  }
................................................................................
    for(p=async.pQueueFirst; p; p = p->pNext){
      if( p->pFile==(AsyncFile *)id ){
        switch( p->op ){
          case ASYNC_WRITE:
            s = MAX(p->iOffset + (i64)(p->nByte), s);
            break;
          case ASYNC_TRUNCATE:
            s = MIN(s, p->iOffset);
            break;
        }
      }
    }
    *pSize = s;
  }
  pthread_mutex_unlock(&async.queueMutex);

Changes to test/async2.test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: async2.test,v 1.1 2006/02/14 13:25:45 danielk1977 Exp $


if {[info commands sqlite3async_enable]==""} {
  # The async logic is not built into this system
  return
}

................................................................................
  db close

  set ::sqlite_io_error_pending $n
  sqlite3async_halt idle
  sqlite3async_start
  sqlite3async_wait

  sqlite3async_enable 0
  set ::sqlite_io_error_pending 0
  sqlite3 db test.db
  set c [db eval {SELECT c FROM counter LIMIT 1}]
  switch -- $c {
    1 {
      do_test async-ioerr-1.1.$n {
        execsql {







|







 







<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
55
56
57
58
59
60
61

62
63
64
65
66
67
68
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: async2.test,v 1.2 2006/02/14 13:48:34 danielk1977 Exp $


if {[info commands sqlite3async_enable]==""} {
  # The async logic is not built into this system
  return
}

................................................................................
  db close

  set ::sqlite_io_error_pending $n
  sqlite3async_halt idle
  sqlite3async_start
  sqlite3async_wait


  set ::sqlite_io_error_pending 0
  sqlite3 db test.db
  set c [db eval {SELECT c FROM counter LIMIT 1}]
  switch -- $c {
    1 {
      do_test async-ioerr-1.1.$n {
        execsql {