/ Check-in [ebbd98e9]
Login

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

Overview
Comment:A couple fixes for the Win32 interface for lsm1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ebbd98e941d8a8ea97b434c29b70095515af0adab1977aa4d37fe74a7401f846
User & Date: mistachkin 2017-06-29 14:17:48
Context
2017-06-29
14:33
Rename the "stmts" virtual table to just "stmt" without the final "s". check-in: adfdb801 user: drh tags: trunk
14:17
A couple fixes for the Win32 interface for lsm1. check-in: ebbd98e9 user: mistachkin tags: trunk
13:41
Add the stmts virtual table to testfixture builds. Add new compile-time options SQLITE_ENABLE_QPSG and SQLITE_ENABLE_STMTSVTAB to ctime.c check-in: 60c62829 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_win32.c.

482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
...
635
636
637
638
639
640
641

642
643
644
645
646
647
648
649
...
665
666
667
668
669
670
671



672
673


674

675

676
677

678
679
680
681
682
683
684
...
757
758
759
760
761
762
763

764
765
766
767
768
769
770
  }
  lsmFree(pEnv, zConverted);
  zTempUtf8 = win32UnicodeToUtf8(pEnv, zTempWide);
  lsmFree(pEnv, zTempWide);
  if( zTempUtf8 ){
    int nOut = *pnOut;
    int nLen = strlen(zTempUtf8) + 1;
    if( nLen>=nOut ){
      lsmFree(pEnv, zTempUtf8);
      return LSM_IOERR_BKPT;
    }
    snprintf(zOut, nOut, "%s", zTempUtf8);
    lsmFree(pEnv, zTempUtf8);
    *pnOut = nLen;
    return LSM_OK;
  }else{
    return LSM_NOMEM_BKPT;
  }
}
................................................................................
  Win32File *pWin32File = (Win32File *)pFile;

  *ppShm = NULL;
  assert( sz>=0 );
  assert( sz==LSM_SHM_CHUNK_SIZE );
  if( iChunk>=pWin32File->nShm ){
    int i;

    void **apNew;
    int nNew = iChunk+1;
    lsm_i64 nReq = nNew * sz;
    LARGE_INTEGER fileSize;

    /* If the shared-memory file has not been opened, open it now. */
    if( pWin32File->hShmFile==NULL ){
      char *zShm = win32ShmFile(pWin32File);
................................................................................
    if( fileSize.QuadPart<nReq ){
      rc = win32Truncate(pWin32File->hShmFile, nReq);
      if( rc!=LSM_OK ){
        return rc;
      }
    }




    apNew = (void **)lsmRealloc(pWin32File->pEnv, pWin32File->apShm,
                                sizeof(LPVOID) * nNew);


    if( !apNew ) return LSM_NOMEM_BKPT;

    for(i=pWin32File->nShm; i<nNew; i++){

      apNew[i] = NULL;
    }

    pWin32File->apShm = apNew;
    pWin32File->nShm = nNew;
  }

  if( pWin32File->apShm[iChunk]==NULL ){
    HANDLE hMap;
    LPVOID pMap;
................................................................................
      break;
    }
    if( ++nRetry>=MX_CLOSE_ATTEMPT ){
      rc = LSM_IOERR_BKPT;
      break;
    }
  }while( 1 );

  lsmFree(pWin32File->pEnv, pWin32File->apShm);
  lsmFree(pWin32File->pEnv, pWin32File);
  return rc;
}

static int lsmWin32OsSleep(lsm_env *pEnv, int us){
  unused_parameter(pEnv);







|
|
<

<







 







>
|







 







>
>
>


>
>
|
>

>


>







 







>







482
483
484
485
486
487
488
489
490

491

492
493
494
495
496
497
498
...
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
...
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
  }
  lsmFree(pEnv, zConverted);
  zTempUtf8 = win32UnicodeToUtf8(pEnv, zTempWide);
  lsmFree(pEnv, zTempWide);
  if( zTempUtf8 ){
    int nOut = *pnOut;
    int nLen = strlen(zTempUtf8) + 1;
    if( nLen<=nOut ){
      snprintf(zOut, nOut, "%s", zTempUtf8);

    }

    lsmFree(pEnv, zTempUtf8);
    *pnOut = nLen;
    return LSM_OK;
  }else{
    return LSM_NOMEM_BKPT;
  }
}
................................................................................
  Win32File *pWin32File = (Win32File *)pFile;

  *ppShm = NULL;
  assert( sz>=0 );
  assert( sz==LSM_SHM_CHUNK_SIZE );
  if( iChunk>=pWin32File->nShm ){
    int i;
    LPHANDLE ahNew;
    LPVOID *apNew;
    int nNew = iChunk+1;
    lsm_i64 nReq = nNew * sz;
    LARGE_INTEGER fileSize;

    /* If the shared-memory file has not been opened, open it now. */
    if( pWin32File->hShmFile==NULL ){
      char *zShm = win32ShmFile(pWin32File);
................................................................................
    if( fileSize.QuadPart<nReq ){
      rc = win32Truncate(pWin32File->hShmFile, nReq);
      if( rc!=LSM_OK ){
        return rc;
      }
    }

    ahNew = (void **)lsmRealloc(pWin32File->pEnv, pWin32File->ahShm,
                                sizeof(LPHANDLE) * nNew);
    if( !ahNew ) return LSM_NOMEM_BKPT;
    apNew = (void **)lsmRealloc(pWin32File->pEnv, pWin32File->apShm,
                                sizeof(LPVOID) * nNew);
    if( !apNew ){
      lsmFree(pWin32File->pEnv, ahNew);
      return LSM_NOMEM_BKPT;
    }
    for(i=pWin32File->nShm; i<nNew; i++){
      ahNew[i] = NULL;
      apNew[i] = NULL;
    }
    pWin32File->ahShm = ahNew;
    pWin32File->apShm = apNew;
    pWin32File->nShm = nNew;
  }

  if( pWin32File->apShm[iChunk]==NULL ){
    HANDLE hMap;
    LPVOID pMap;
................................................................................
      break;
    }
    if( ++nRetry>=MX_CLOSE_ATTEMPT ){
      rc = LSM_IOERR_BKPT;
      break;
    }
  }while( 1 );
  lsmFree(pWin32File->pEnv, pWin32File->ahShm);
  lsmFree(pWin32File->pEnv, pWin32File->apShm);
  lsmFree(pWin32File->pEnv, pWin32File);
  return rc;
}

static int lsmWin32OsSleep(lsm_env *pEnv, int us){
  unused_parameter(pEnv);