/ Check-in [4df6e247]
Login

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

Overview
Comment:Further corrections to the Win32 interface for lsm1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:4df6e2476ce93b9ca7a6959c8c2d6ef2c30395984b007d74166031dcf09d54b4
User & Date: mistachkin 2017-06-29 15:13:48
Context
2017-06-29
15:24
Add interfaces sqlite3_prepare_v3() and sqlite3_prepare16_v3() with the extra prepFlags argument. Add the SQLITE_PREPARE_PERSISTENT option as one bit in that argument. Use the new option in FTS3, FTS5, and RTREE. check-in: 03977248 user: drh tags: trunk
15:13
Further corrections to the Win32 interface for lsm1. check-in: 4df6e247 user: mistachkin tags: trunk
14:33
Rename the "stmts" virtual table to just "stmt" without the final "s". check-in: adfdb801 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_win32.c.

567
568
569
570
571
572
573





574
575
576
577
578
579
580
...
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
...
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
...
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697



698
699
700
701
702
703
704
705
706
707
708
709
710
711
  lsmFree(pEnv, zConverted);
  return rc;
}

static int lsmWin32OsUnlink(lsm_env *pEnv, const char *zFile){
  return win32Delete(pEnv, zFile);
}






int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){
  Win32File *pWin32File = (Win32File *)pFile;
  OVERLAPPED ovlp;

  assert( LSM_LOCK_UNLOCK==0 );
  assert( LSM_LOCK_SHARED==1 );
................................................................................

  memset(&ovlp, 0, sizeof(OVERLAPPED));
  ovlp.Offset = (4096-iLock);
  if( eType>LSM_LOCK_UNLOCK ){
    DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
    if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
    if( !LockFileEx(pWin32File->hFile, flags, 0, 1, 0, &ovlp) ){
      if( GetLastError()==ERROR_IO_PENDING ){
        return LSM_BUSY;
      }else{
        return LSM_IOERR_BKPT;
      }
    }
  }else{
    if( !UnlockFileEx(pWin32File->hFile, 0, 1, 0, &ovlp) ){
................................................................................
  assert( nLock>=0 );
  assert( iLock>0 && iLock<=32 );

  if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
  memset(&ovlp, 0, sizeof(OVERLAPPED));
  ovlp.Offset = (4096-iLock);
  if( !LockFileEx(pWin32File->hFile, flags, 0, (DWORD)nLock, 0, &ovlp) ){
    if( GetLastError()==ERROR_IO_PENDING ){
      return LSM_BUSY;
    }else{
      return LSM_IOERR_BKPT;
    }
  }
  UnlockFileEx(pWin32File->hFile, 0, (DWORD)nLock, 0, &ovlp);
  return LSM_OK;
................................................................................
      apNew[i] = NULL;
    }
    pWin32File->ahShm = ahNew;
    pWin32File->apShm = apNew;
    pWin32File->nShm = nNew;
  }

  if( pWin32File->apShm[iChunk]==NULL ){
    HANDLE hMap;
    LPVOID pMap;
    hMap = CreateFileMappingW(pWin32File->hShmFile, NULL, PAGE_READWRITE, 0,
                              (DWORD)sz, NULL);
    if( hMap==NULL ){
      return LSM_IOERR_BKPT;
    }
    pWin32File->ahShm[iChunk] = hMap;



    pMap = MapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0,
                         (SIZE_T)sz);
    if( pMap==NULL ){
      return LSM_IOERR_BKPT;
    }
    pWin32File->apShm[iChunk] = pMap;
    pWin32File->nMap = (SIZE_T)sz;
  }
  *ppShm = pWin32File->apShm[iChunk];
  return LSM_OK;
}

void lsmWin32OsShmBarrier(void){
  MemoryBarrier();







>
>
>
>
>







 







|







 







|







 







|

<






>
>
>
|
|




<







567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
...
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
...
687
688
689
690
691
692
693
694
695

696
697
698
699
700
701
702
703
704
705
706
707
708
709
710

711
712
713
714
715
716
717
  lsmFree(pEnv, zConverted);
  return rc;
}

static int lsmWin32OsUnlink(lsm_env *pEnv, const char *zFile){
  return win32Delete(pEnv, zFile);
}

#if !defined(win32IsLockBusy)
#define win32IsLockBusy(a) (((a)==ERROR_LOCK_VIOLATION) || \
                            ((a)==ERROR_IO_PENDING))
#endif

int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){
  Win32File *pWin32File = (Win32File *)pFile;
  OVERLAPPED ovlp;

  assert( LSM_LOCK_UNLOCK==0 );
  assert( LSM_LOCK_SHARED==1 );
................................................................................

  memset(&ovlp, 0, sizeof(OVERLAPPED));
  ovlp.Offset = (4096-iLock);
  if( eType>LSM_LOCK_UNLOCK ){
    DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
    if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
    if( !LockFileEx(pWin32File->hFile, flags, 0, 1, 0, &ovlp) ){
      if( win32IsLockBusy(GetLastError()) ){
        return LSM_BUSY;
      }else{
        return LSM_IOERR_BKPT;
      }
    }
  }else{
    if( !UnlockFileEx(pWin32File->hFile, 0, 1, 0, &ovlp) ){
................................................................................
  assert( nLock>=0 );
  assert( iLock>0 && iLock<=32 );

  if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;
  memset(&ovlp, 0, sizeof(OVERLAPPED));
  ovlp.Offset = (4096-iLock);
  if( !LockFileEx(pWin32File->hFile, flags, 0, (DWORD)nLock, 0, &ovlp) ){
    if( win32IsLockBusy(GetLastError()) ){
      return LSM_BUSY;
    }else{
      return LSM_IOERR_BKPT;
    }
  }
  UnlockFileEx(pWin32File->hFile, 0, (DWORD)nLock, 0, &ovlp);
  return LSM_OK;
................................................................................
      apNew[i] = NULL;
    }
    pWin32File->ahShm = ahNew;
    pWin32File->apShm = apNew;
    pWin32File->nShm = nNew;
  }

  if( pWin32File->ahShm[iChunk]==NULL ){
    HANDLE hMap;

    hMap = CreateFileMappingW(pWin32File->hShmFile, NULL, PAGE_READWRITE, 0,
                              (DWORD)sz, NULL);
    if( hMap==NULL ){
      return LSM_IOERR_BKPT;
    }
    pWin32File->ahShm[iChunk] = hMap;
  }
  if( pWin32File->apShm[iChunk]==NULL ){
    LPVOID pMap;
    pMap = MapViewOfFile(pWin32File->ahShm[iChunk],
                         FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, (SIZE_T)sz);
    if( pMap==NULL ){
      return LSM_IOERR_BKPT;
    }
    pWin32File->apShm[iChunk] = pMap;

  }
  *ppShm = pWin32File->apShm[iChunk];
  return LSM_OK;
}

void lsmWin32OsShmBarrier(void){
  MemoryBarrier();