亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os_unix.c

?? sqlite 3.3.8 支持加密的版本
?? C
?? 第 1 頁 / 共 5 頁
字號:
      int i;
      for(i=0; i<pOpen->nPending; i++){
        close(pOpen->aPending[i]);
      }
      free(pOpen->aPending);
      pOpen->nPending = 0;
      pOpen->aPending = 0;
    }
  }
  sqlite3OsLeaveMutex();
  pFile->locktype = locktype;
  return rc;
}

/*
** Close a file.
*/
static int unixClose(OsFile **pId){
  unixFile *id = (unixFile*)*pId;

  if( !id ) return SQLITE_OK;
  unixUnlock(*pId, NO_LOCK);
  if( id->dirfd>=0 ) close(id->dirfd);
  id->dirfd = -1;
  sqlite3OsEnterMutex();

  if( id->pOpen->nLock ){
    /* If there are outstanding locks, do not actually close the file just
    ** yet because that would clear those locks.  Instead, add the file
    ** descriptor to pOpen->aPending.  It will be automatically closed when
    ** the last lock is cleared.
    */
    int *aNew;
    struct openCnt *pOpen = id->pOpen;
    aNew = realloc( pOpen->aPending, (pOpen->nPending+1)*sizeof(int) );
    if( aNew==0 ){
      /* If a malloc fails, just leak the file descriptor */
    }else{
      pOpen->aPending = aNew;
      pOpen->aPending[pOpen->nPending] = id->h;
      pOpen->nPending++;
    }
  }else{
    /* There are no outstanding locks so we can close the file immediately */
    close(id->h);
  }
  releaseLockInfo(id->pLock);
  releaseOpenCnt(id->pOpen);

  sqlite3OsLeaveMutex();
  id->isOpen = 0;
  TRACE2("CLOSE   %-3d\n", id->h);
  OpenCounter(-1);
  sqlite3ThreadSafeFree(id);
  *pId = 0;
  return SQLITE_OK;
}


#ifdef SQLITE_ENABLE_LOCKING_STYLE
#pragma mark AFP Support

/*
 ** The afpLockingContext structure contains all afp lock specific state
 */
typedef struct afpLockingContext afpLockingContext;
struct afpLockingContext {
  unsigned long long sharedLockByte;
  char *filePath;
};

struct ByteRangeLockPB2
{
  unsigned long long offset;        /* offset to first byte to lock */
  unsigned long long length;        /* nbr of bytes to lock */
  unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */
  unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */
  unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */
  int fd;                           /* file desc to assoc this lock with */
};

#define afpfsByteRangeLock2FSCTL	_IOWR('z', 23, struct ByteRangeLockPB2)

/* return 0 on success, 1 on failure.  To match the behavior of the 
  normal posix file locking (used in unixLock for example), we should 
  provide 'richer' return codes - specifically to differentiate between
  'file busy' and 'file system error' results */
static int _AFPFSSetLock(const char *path, int fd, unsigned long long offset, 
                         unsigned long long length, int setLockFlag)
{
  struct ByteRangeLockPB2	pb;
  int                     err;
  
  pb.unLockFlag = setLockFlag ? 0 : 1;
  pb.startEndFlag = 0;
  pb.offset = offset;
  pb.length = length; 
  pb.fd = fd;
  TRACE5("AFPLOCK setting lock %s for %d in range %llx:%llx\n", 
    (setLockFlag?"ON":"OFF"), fd, offset, length);
  err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);
  if ( err==-1 ) {
    TRACE4("AFPLOCK failed to fsctl() '%s' %d %s\n", path, errno, 
      strerror(errno));
    return 1; // error
  } else {
    return 0;
  }
}

/*
 ** This routine checks if there is a RESERVED lock held on the specified
 ** file by this or any other process. If such a lock is held, return
 ** non-zero.  If the file is unlocked or holds only SHARED locks, then
 ** return zero.
 */
static int afpUnixCheckReservedLock(OsFile *id){
  int r = 0;
  unixFile *pFile = (unixFile*)id;
  
  assert( pFile ); 
  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
  
  /* Check if a thread in this process holds such a lock */
  if( pFile->locktype>SHARED_LOCK ){
    r = 1;
  }
  
  /* Otherwise see if some other process holds it.
   */
  if ( !r ) {
    // lock the byte
    int failed = _AFPFSSetLock(context->filePath, pFile->h, RESERVED_BYTE, 1,1);  
    if (failed) {
      /* if we failed to get the lock then someone else must have it */
      r = 1;
    } else {
      /* if we succeeded in taking the reserved lock, unlock it to restore
      ** the original state */
      _AFPFSSetLock(context->filePath, pFile->h, RESERVED_BYTE, 1, 0);
    }
  }
  TRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
  
  return r;
}

/* AFP-style locking following the behavior of unixLock, see the unixLock 
** function comments for details of lock management. */
static int afpUnixLock(OsFile *id, int locktype)
{
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile*)id;
  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
  int gotPendingLock = 0;
  
  assert( pFile );
  TRACE5("LOCK    %d %s was %s pid=%d\n", pFile->h,
         locktypeName(locktype), locktypeName(pFile->locktype), getpid());  
  /* If there is already a lock of this type or more restrictive on the
    ** OsFile, do nothing. Don't use the afp_end_lock: exit path, as
    ** sqlite3OsEnterMutex() hasn't been called yet.
    */
  if( pFile->locktype>=locktype ){
    TRACE3("LOCK    %d %s ok (already held)\n", pFile->h,
           locktypeName(locktype));
    return SQLITE_OK;
  }

  /* Make sure the locking sequence is correct
    */
  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );
  assert( locktype!=PENDING_LOCK );
  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );
  
  /* This mutex is needed because pFile->pLock is shared across threads
    */
  sqlite3OsEnterMutex();

  /* Make sure the current thread owns the pFile.
    */
  rc = transferOwnership(pFile);
  if( rc!=SQLITE_OK ){
    sqlite3OsLeaveMutex();
    return rc;
  }
    
  /* A PENDING lock is needed before acquiring a SHARED lock and before
    ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will
    ** be released.
    */
  if( locktype==SHARED_LOCK 
      || (locktype==EXCLUSIVE_LOCK && pFile->locktype<PENDING_LOCK)
      ){
    int failed = _AFPFSSetLock(context->filePath, pFile->h, 
      PENDING_BYTE, 1, 1);
    if (failed) {
      rc = SQLITE_BUSY;
      goto afp_end_lock;
    }
  }
  
  /* If control gets to this point, then actually go ahead and make
    ** operating system calls for the specified lock.
    */
  if( locktype==SHARED_LOCK ){
    int lk, failed;
    int tries = 0;
    
    /* Now get the read-lock */
    /* note that the quality of the randomness doesn't matter that much */
    lk = random(); 
    context->sharedLockByte = (lk & 0x7fffffff)%(SHARED_SIZE - 1);
    failed = _AFPFSSetLock(context->filePath, pFile->h, 
      SHARED_FIRST+context->sharedLockByte, 1, 1);
    
    /* Drop the temporary PENDING lock */
    if (_AFPFSSetLock(context->filePath, pFile->h, PENDING_BYTE, 1, 0)) {
      rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
      goto afp_end_lock;
    }
    
    if( failed ){
      rc = SQLITE_BUSY;
    } else {
      pFile->locktype = SHARED_LOCK;
    }
  }else{
    /* The request was for a RESERVED or EXCLUSIVE lock.  It is
    ** assumed that there is a SHARED or greater lock on the file
    ** already.
    */
    int failed = 0;
    assert( 0!=pFile->locktype );
    if (locktype >= RESERVED_LOCK && pFile->locktype < RESERVED_LOCK) {
        /* Acquire a RESERVED lock */
        failed = _AFPFSSetLock(context->filePath, pFile->h, RESERVED_BYTE, 1,1);
    }
    if (!failed && locktype == EXCLUSIVE_LOCK) {
      /* Acquire an EXCLUSIVE lock */
        
      /* Remove the shared lock before trying the range.  we'll need to 
      ** reestablish the shared lock if we can't get the  afpUnixUnlock
      */
      if (!_AFPFSSetLock(context->filePath, pFile->h, SHARED_FIRST +
                         context->sharedLockByte, 1, 0)) {
        /* now attemmpt to get the exclusive lock range */
        failed = _AFPFSSetLock(context->filePath, pFile->h, SHARED_FIRST, 
                               SHARED_SIZE, 1);
        if (failed && _AFPFSSetLock(context->filePath, pFile->h, SHARED_FIRST +
                                    context->sharedLockByte, 1, 1)) {
          rc = SQLITE_IOERR_RDLOCK; /* this should never happen */
        }
      } else {
        /* */
        rc = SQLITE_IOERR_UNLOCK; /* this should never happen */
      }
    }
    if( failed && rc == SQLITE_OK){
      rc = SQLITE_BUSY;
    }
  }
  
  if( rc==SQLITE_OK ){
    pFile->locktype = locktype;
  }else if( locktype==EXCLUSIVE_LOCK ){
    pFile->locktype = PENDING_LOCK;
  }
  
afp_end_lock:
    sqlite3OsLeaveMutex();
  TRACE4("LOCK    %d %s %s\n", pFile->h, locktypeName(locktype), 
         rc==SQLITE_OK ? "ok" : "failed");
  return rc;
}

/*
 ** Lower the locking level on file descriptor pFile to locktype.  locktype
 ** must be either NO_LOCK or SHARED_LOCK.
 **
 ** If the locking level of the file descriptor is already at or below
 ** the requested locking level, this routine is a no-op.
 */
static int afpUnixUnlock(OsFile *id, int locktype) {
  struct flock lock;
  int rc = SQLITE_OK;
  unixFile *pFile = (unixFile*)id;
  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;

  assert( pFile );
  TRACE5("UNLOCK  %d %d was %d pid=%d\n", pFile->h, locktype,
         pFile->locktype, getpid());
  
  assert( locktype<=SHARED_LOCK );
  if( pFile->locktype<=locktype ){
    return SQLITE_OK;
  }
  if( CHECK_THREADID(pFile) ){
    return SQLITE_MISUSE;
  }
  sqlite3OsEnterMutex();
  if( pFile->locktype>SHARED_LOCK ){
    if( locktype==SHARED_LOCK ){
      int failed = 0;

      /* unlock the exclusive range - then re-establish the shared lock */
      if (pFile->locktype==EXCLUSIVE_LOCK) {
        failed = _AFPFSSetLock(context->filePath, pFile->h, SHARED_FIRST, 
                                 SHARED_SIZE, 0);
        if (!failed) {
          /* successfully removed the exclusive lock */
          if (_AFPFSSetLock(context->filePath, pFile->h, SHARED_FIRST+
                            context->sharedLockByte, 1, 1)) {
            /* failed to re-establish our shared lock */
            rc = SQLITE_IOERR_RDLOCK; /* This should never happen */
          }
        } else {
          /* This should never happen - failed to unlock the exclusive range */
          rc = SQLITE_IOERR_UNLOCK;
        } 
      }
    }
    if (rc == SQLITE_OK && pFile->locktype>=PENDING_LOCK) {
      if (_AFPFSSetLock(context->filePath, pFile->h, PENDING_BYTE, 1, 0)){
        /* failed to release the pending lock */
        rc = SQLITE_IOERR_UNLOCK; /* This should never happen */
      }
    } 
    if (rc == SQLITE_OK && pFile->locktype>=RESERVED_LOCK) {
      if (_AFPFSSetLock(context->filePath, pFile->h, RESERVED_BYTE, 1, 0)) {
        /* failed to release the reserved lock */
        rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
      }
    } 
  }
  if( locktype==NO_LOCK ){
    int failed = _AFPFSSetLock(context->filePath, pFile->h, 
                               SHARED_FIRST + context->sharedLockByte, 1, 0);
    if (failed) {
      rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
    }
  }
  if (rc == SQLITE_OK)
    pFile->locktype = locktype;
  sqlite3OsLeaveMutex();
  return rc;
}

/*
 ** Close a file & cleanup AFP specific locking context 
 */
static int afpUnixClose(OsFile **pId) {
  unixFile *id = (unixFile*)*pId;
  
  if( !id ) return SQLITE_OK;
  afpUnixUnlock(*pId, NO_LOCK);
  /* free the AFP locking structure */
  if (id->lockingContext != NULL) {
    if (((afpLockingContext *)id->lockingContext)->filePath != NULL)
      sqlite3ThreadSafeFree(((afpLockingContext*)id->lockingContext)->filePath);
    sqlite3ThreadSafeFree(id->lockingContext);
  }
  
  if( id->dirfd>=0 ) close(id->dirfd);
  id->dirfd = -1;
  close(id->h);
  id->isOpen = 0;
  TRACE2("CLOSE   %-3d\n", id->h);
  OpenCounter(-1);
  sqlite3ThreadSafeFree(id);
  *pId = 0;
  return SQLITE_OK;
}


#pragma mark flock() style locking

/*
 ** The flockLockingContext is not used
 */
typedef void flockLockingContext;

static int flockUnixCheckReservedLock(OsFile *id) {
  unixFile *pFile = (unixFile*)id;
  
  if (pFile->locktype == RESERVED_LOCK) {
    return 1; // already have a reserved lock
  } else {
    // attempt to get the lock
    int rc = flock(pFile->h, LOCK_EX | LOCK_NB);
    if (!rc) {
      // got the lock, unlock it
      flock(pFile->h, LOCK_UN);
      return 0;  // no one has it reserved
    }
    return 1; // someone else might have it reserved
  }
}

static int flockUnixLock(OsFile 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69av一区二区三区| 亚洲精品一区二区三区四区高清| 欧美中文字幕亚洲一区二区va在线| 欧美日韩aaaaa| 国产欧美日韩激情| 美国十次了思思久久精品导航| 91啪九色porn原创视频在线观看| 日韩天堂在线观看| 亚洲国产成人91porn| 99久久综合狠狠综合久久| 欧美不卡一区二区| 午夜国产精品一区| 91看片淫黄大片一级在线观看| 久久久夜色精品亚洲| 久久成人免费日本黄色| 欧美日韩一区二区电影| 成人免费在线播放视频| 福利一区二区在线| 久久久综合精品| 国内精品第一页| 日韩限制级电影在线观看| 亚洲大片精品永久免费| 色综合中文字幕国产| 久久老女人爱爱| 国产一区二区三区精品欧美日韩一区二区三区 | 国产精品剧情在线亚洲| 日本不卡一区二区三区| 欧美日韩三级视频| 亚洲国产精品久久艾草纯爱| 日本韩国精品在线| 一区二区三区 在线观看视频| 91浏览器打开| 亚洲午夜激情网站| 91免费视频网址| 一区二区三区四区在线| 日本精品一区二区三区高清| 一个色综合av| 91精品国产综合久久久蜜臀图片 | 欧美日韩一区二区在线观看| 亚洲综合男人的天堂| 色狠狠一区二区三区香蕉| 亚洲精品免费在线播放| 欧美中文字幕一区二区三区 | 欧美视频一区二区在线观看| 亚洲一级不卡视频| 欧美喷水一区二区| 九一久久久久久| 精品国产一区二区在线观看| 国产在线看一区| 久久看人人爽人人| 91香蕉视频污| 午夜精品福利一区二区蜜股av | 欧美老肥妇做.爰bbww| 日韩精品一二区| 精品日韩在线一区| 国产高清精品在线| 亚洲精品国产一区二区精华液| 欧美手机在线视频| 国内精品国产成人国产三级粉色| 欧美国产一区二区| 欧美在线观看一二区| 毛片av一区二区三区| 中文字幕免费观看一区| 欧美性色aⅴ视频一区日韩精品| 蜜臀av一区二区在线免费观看 | 精品国产乱子伦一区| 成人短视频下载| 亚洲第一综合色| 久久久国产精品麻豆| 欧美日本国产视频| 丁香激情综合国产| 亚洲成人激情综合网| 欧美精品一区二区三区蜜臀| 91老师国产黑色丝袜在线| 久久国产综合精品| 亚洲精品久久7777| 国产网站一区二区三区| 欧美日韩精品一区二区| 国产不卡在线视频| 男女视频一区二区| 亚洲伦理在线精品| 久久久亚洲精华液精华液精华液| 精品视频资源站| 99re成人精品视频| 亚洲国产wwwccc36天堂| 136国产福利精品导航| 欧美草草影院在线视频| 欧美性生交片4| av在线播放不卡| 激情综合色播激情啊| 亚洲成人av一区二区| 亚洲手机成人高清视频| 久久精品免视看| 欧美mv和日韩mv国产网站| 欧美亚洲自拍偷拍| 91年精品国产| jlzzjlzz亚洲女人18| 国产美女一区二区三区| 日本欧洲一区二区| 性做久久久久久免费观看欧美| 亚洲天堂免费在线观看视频| 国产精品污网站| 国产日产欧美精品一区二区三区| 欧美白人最猛性xxxxx69交| 欧美男男青年gay1069videost | 一区二区三区精品在线| 国产精品久久久99| 国产喂奶挤奶一区二区三区| 久久久久久久久久久99999| 日韩一区二区三区精品视频| 欧美片网站yy| 91麻豆精品久久久久蜜臀| 制服丝袜激情欧洲亚洲| 欧美日韩午夜在线视频| 欧美三级视频在线| 欧美日韩国产乱码电影| 欧美日韩色一区| 欧美一区二区三区四区五区| 日韩一区二区中文字幕| 精品久久人人做人人爽| 精品国产伦理网| 国产精品无遮挡| 亚洲女与黑人做爰| 亚洲最大成人综合| 偷窥少妇高潮呻吟av久久免费| 亚洲成人精品在线观看| 奇米色一区二区| 国产精品99久久久久久似苏梦涵 | 国产精品久久久99| 亚洲乱码精品一二三四区日韩在线| 一区二区三区精品在线| 日本视频中文字幕一区二区三区| 精品一区二区在线观看| 成人午夜碰碰视频| 色诱视频网站一区| 欧美绝品在线观看成人午夜影视| 91麻豆精品国产91久久久| 日韩精品一区国产麻豆| 久久久精品免费网站| 亚洲精品中文在线| 日本午夜一区二区| 高清久久久久久| 欧美日韩久久久久久| 26uuu国产一区二区三区| 国产精品美女久久福利网站| 亚洲综合成人在线视频| 精品写真视频在线观看| jizz一区二区| 日韩一区二区在线看| 国产精品女同互慰在线看| 亚洲激情在线激情| 黄色日韩三级电影| 色综合久久中文字幕综合网 | 91视视频在线直接观看在线看网页在线看| 在线免费一区三区| 精品噜噜噜噜久久久久久久久试看| 一区二区三区四区国产精品| 奇米亚洲午夜久久精品| 波多野结衣亚洲| 日韩欧美视频在线 | 国产三区在线成人av| 亚洲免费视频中文字幕| 久久超碰97人人做人人爱| 色综合中文字幕| 国产午夜精品理论片a级大结局| 亚洲一二三四在线观看| 国产高清精品在线| 欧美一区二区日韩| 一区二区三区四区在线免费观看| 国模娜娜一区二区三区| 欧美日韩精品免费观看视频| 国产精品素人视频| 久久电影国产免费久久电影| 91电影在线观看| 国产精品二三区| 国产成人精品亚洲日本在线桃色| 欧美日韩免费电影| 亚洲欧洲日韩av| 国产精品中文字幕日韩精品 | 国产一区二区三区四区五区入口| 一本大道久久a久久综合婷婷| 日韩欧美国产综合| 亚洲高清不卡在线| 91女厕偷拍女厕偷拍高清| 国产精品嫩草99a| 国产成人在线看| 精品久久久久一区| 日韩高清不卡一区二区三区| 欧美三级日本三级少妇99| 中文字幕在线观看不卡视频| 国产乱子伦视频一区二区三区| 欧美日韩国产高清一区二区三区| 亚洲欧美另类久久久精品| 波多野结衣91| 国产精品久久久久一区二区三区共| 国产一区美女在线| 精品国产乱码久久久久久免费| 日韩av一区二区三区| 在线综合视频播放| 美女视频免费一区|