~ubuntu-branches/ubuntu/precise/sqlite3/precise-updates

« back to all changes in this revision

Viewing changes to ext/async/sqlite3async.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-12-11 14:34:09 UTC
  • mfrom: (9.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091211143409-o29fahwmcmyd0vq1
Tags: 3.6.21-2
Run autoreconf to prevent FTBFS with new libtool (closes: #560660).

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
**
11
11
*************************************************************************
12
12
**
13
 
** $Id: sqlite3async.c,v 1.6 2009/04/30 17:45:34 shane Exp $
 
13
** $Id: sqlite3async.c,v 1.7 2009/07/18 11:52:04 danielk1977 Exp $
14
14
**
15
15
** This file contains the implementation of an asynchronous IO backend 
16
16
** for SQLite.
668
668
  AsyncFileData *p = ((AsyncFile *)pFile)->pData;
669
669
  int rc = SQLITE_OK;
670
670
  sqlite3_int64 filesize;
671
 
  int nRead;
672
671
  sqlite3_file *pBase = p->pBaseRead;
 
672
  sqlite3_int64 iAmt64 = (sqlite3_int64)iAmt;
673
673
 
674
674
  /* Grab the write queue mutex for the duration of the call */
675
675
  async_mutex_enter(ASYNC_MUTEX_QUEUE);
683
683
  }
684
684
 
685
685
  if( pBase->pMethods ){
 
686
    sqlite3_int64 nRead;
686
687
    rc = pBase->pMethods->xFileSize(pBase, &filesize);
687
688
    if( rc!=SQLITE_OK ){
688
689
      goto asyncread_out;
689
690
    }
690
 
    nRead = (int)MIN(filesize - iOffset, iAmt);
 
691
    nRead = MIN(filesize - iOffset, iAmt64);
691
692
    if( nRead>0 ){
692
693
      rc = pBase->pMethods->xRead(pBase, zOut, nRead, iOffset);
693
694
      ASYNC_TRACE(("READ %s %d bytes at %d\n", p->zName, nRead, iOffset));
703
704
        (pWrite->pFileData==p) ||
704
705
        (zName && pWrite->pFileData->zName==zName)
705
706
      )){
 
707
        sqlite3_int64 nCopy;
 
708
        sqlite3_int64 nByte64 = (sqlite3_int64)pWrite->nByte;
 
709
 
 
710
        /* Set variable iBeginIn to the offset in buffer pWrite->zBuf[] from
 
711
        ** which data should be copied. Set iBeginOut to the offset within
 
712
        ** the output buffer to which data should be copied. If either of
 
713
        ** these offsets is a negative number, set them to 0.
 
714
        */
706
715
        sqlite3_int64 iBeginOut = (pWrite->iOffset-iOffset);
707
716
        sqlite3_int64 iBeginIn = -iBeginOut;
708
 
        int nCopy;
709
 
 
710
717
        if( iBeginIn<0 ) iBeginIn = 0;
711
718
        if( iBeginOut<0 ) iBeginOut = 0;
712
 
        nCopy = (int)MIN(pWrite->nByte-iBeginIn, iAmt-iBeginOut);
713
719
 
 
720
        nCopy = MIN(nByte64-iBeginIn, iAmt64-iBeginOut);
714
721
        if( nCopy>0 ){
715
722
          memcpy(&((char *)zOut)[iBeginOut], &pWrite->zBuf[iBeginIn], nCopy);
716
723
          ASYNC_TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset));
1065
1072
  if( !isAsyncOpen ){
1066
1073
    int flagsout;
1067
1074
    rc = pVfs->xOpen(pVfs, pData->zName, pData->pBaseRead, flags, &flagsout);
1068
 
    if( rc==SQLITE_OK && (flagsout&SQLITE_OPEN_READWRITE) ){
 
1075
    if( rc==SQLITE_OK 
 
1076
     && (flagsout&SQLITE_OPEN_READWRITE) 
 
1077
     && (flags&SQLITE_OPEN_EXCLUSIVE)==0
 
1078
    ){
1069
1079
      rc = pVfs->xOpen(pVfs, pData->zName, pData->pBaseWrite, flags, 0);
1070
1080
    }
1071
1081
    if( pOutFlags ){
1221
1231
  */
1222
1232
  if( rc==SQLITE_OK ){
1223
1233
    int i, j;
1224
 
    int n = nPathOut;
1225
1234
    char *z = zPathOut;
 
1235
    int n = strlen(z);
1226
1236
    while( n>1 && z[n-1]=='/' ){ n--; }
1227
1237
    for(i=j=0; i<n; i++){
1228
1238
      if( z[i]=='/' ){