/ Check-in [9112117d]
Login

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

Overview
Comment:Implement xLock and xTestLock for lsm1 on Win32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lsm-vtab
Files: files | file ages | folders
SHA3-256: 9112117dad8085c385aa614cd982b307f5822761607ba358f34df7848c549134
User & Date: mistachkin 2017-06-28 21:36:40
Context
2017-06-29
00:20
Implement xRemap for lsm1 on Win32. Also, zero file handle when closing it. check-in: 93c9aa7d user: mistachkin tags: lsm-vtab
2017-06-28
21:36
Implement xLock and xTestLock for lsm1 on Win32. check-in: 9112117d user: mistachkin tags: lsm-vtab
2017-06-27
22:33
Improve a local variable name. check-in: d0f6973d user: mistachkin tags: lsm-vtab
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_win32.c.

455
456
457
458
459
460
461


























462
463
464
465






















466
467
468
469
470
471
472
473
}

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

int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){


























  return LSM_ERROR;
}

int lsmWin32OsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){






















  return LSM_ERROR;
}

int lsmWin32OsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){
  return LSM_ERROR;
}

void lsmWin32OsShmBarrier(void){







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
}

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

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 );
  assert( LSM_LOCK_EXCL==2 );
  assert( eType>=LSM_LOCK_UNLOCK && eType<=LSM_LOCK_EXCL );
  assert( iLock>0 && iLock<=32 );

  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) ){
      return LSM_IOERR_BKPT;
    }
  }
  return LSM_OK;
}

int lsmWin32OsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){
  Win32File *pWin32File = (Win32File *)pFile;
  DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
  OVERLAPPED ovlp;

  assert( LSM_LOCK_UNLOCK==0 );
  assert( LSM_LOCK_SHARED==1 );
  assert( LSM_LOCK_EXCL==2 );
  assert( eType==LSM_LOCK_SHARED || eType==LSM_LOCK_EXCL );
  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;
}

int lsmWin32OsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){
  return LSM_ERROR;
}

void lsmWin32OsShmBarrier(void){