/ Check-in [8d0073c0]
Login

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

Overview
Comment:Assume any return code from fcntl() other than -1 is success. Formerly we only assumed that 0 was success. Ticket #2173. (CVS 3754)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8d0073c0e8408558dae39f789ac3fa2622b52365
User & Date: drh 2007-03-29 20:19:59
Context
2007-03-30
07:10
Extra test cases to improve coverage of main.c. (CVS 3755) check-in: 19fc3d78 user: danielk1977 tags: trunk
2007-03-29
20:19
Assume any return code from fcntl() other than -1 is success. Formerly we only assumed that 0 was success. Ticket #2173. (CVS 3754) check-in: 8d0073c0 user: drh tags: trunk
20:13
Fix to token destructors in Lemon. This does not impact SQLite. Ticket #2175. (CVS 3753) check-in: 6195af49 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   453    453     }
   454    454     assert( p->l_whence==SEEK_SET );
   455    455     s = fcntl(fd, op, p);
   456    456     savedErrno = errno;
   457    457     sqlite3DebugPrintf("fcntl %d %d %s %s %d %d %d %d\n",
   458    458        threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len,
   459    459        (int)p->l_pid, s);
   460         -  if( s && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){
          460  +  if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){
   461    461       struct flock l2;
   462    462       l2 = *p;
   463    463       fcntl(fd, F_GETLK, &l2);
   464    464       if( l2.l_type==F_RDLCK ){
   465    465         zType = "RDLCK";
   466    466       }else if( l2.l_type==F_WRLCK ){
   467    467         zType = "WRLCK";
................................................................................
  1480   1480     */
  1481   1481     if( locktype==SHARED_LOCK 
  1482   1482         || (locktype==EXCLUSIVE_LOCK && pFile->locktype<PENDING_LOCK)
  1483   1483     ){
  1484   1484       lock.l_type = (locktype==SHARED_LOCK?F_RDLCK:F_WRLCK);
  1485   1485       lock.l_start = PENDING_BYTE;
  1486   1486       s = fcntl(pFile->h, F_SETLK, &lock);
  1487         -    if( s ){
         1487  +    if( s==(-1) ){
  1488   1488         rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;
  1489   1489         goto end_lock;
  1490   1490       }
  1491   1491     }
  1492   1492   
  1493   1493   
  1494   1494     /* If control gets to this point, then actually go ahead and make
................................................................................
  1507   1507       lock.l_start = PENDING_BYTE;
  1508   1508       lock.l_len = 1L;
  1509   1509       lock.l_type = F_UNLCK;
  1510   1510       if( fcntl(pFile->h, F_SETLK, &lock)!=0 ){
  1511   1511         rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
  1512   1512         goto end_lock;
  1513   1513       }
  1514         -    if( s ){
         1514  +    if( s==(-1) ){
  1515   1515         rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;
  1516   1516       }else{
  1517   1517         pFile->locktype = SHARED_LOCK;
  1518   1518         pFile->pOpen->nLock++;
  1519   1519         pLock->cnt = 1;
  1520   1520       }
  1521   1521     }else if( locktype==EXCLUSIVE_LOCK && pLock->cnt>1 ){
................................................................................
  1537   1537           lock.l_start = SHARED_FIRST;
  1538   1538           lock.l_len = SHARED_SIZE;
  1539   1539           break;
  1540   1540         default:
  1541   1541           assert(0);
  1542   1542       }
  1543   1543       s = fcntl(pFile->h, F_SETLK, &lock);
  1544         -    if( s ){
         1544  +    if( s==(-1) ){
  1545   1545         rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;
  1546   1546       }
  1547   1547     }
  1548   1548     
  1549   1549     if( rc==SQLITE_OK ){
  1550   1550       pFile->locktype = locktype;
  1551   1551       pLock->locktype = locktype;
................................................................................
  1591   1591     if( pFile->locktype>SHARED_LOCK ){
  1592   1592       assert( pLock->locktype==pFile->locktype );
  1593   1593       if( locktype==SHARED_LOCK ){
  1594   1594         lock.l_type = F_RDLCK;
  1595   1595         lock.l_whence = SEEK_SET;
  1596   1596         lock.l_start = SHARED_FIRST;
  1597   1597         lock.l_len = SHARED_SIZE;
  1598         -      if( fcntl(pFile->h, F_SETLK, &lock)!=0 ){
         1598  +      if( fcntl(pFile->h, F_SETLK, &lock)==(-1) ){
  1599   1599           /* This should never happen */
  1600   1600           rc = SQLITE_IOERR_RDLOCK;
  1601   1601         }
  1602   1602       }
  1603   1603       lock.l_type = F_UNLCK;
  1604   1604       lock.l_whence = SEEK_SET;
  1605   1605       lock.l_start = PENDING_BYTE;
  1606   1606       lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );
  1607         -    if( fcntl(pFile->h, F_SETLK, &lock)==0 ){
         1607  +    if( fcntl(pFile->h, F_SETLK, &lock)!=(-1) ){
  1608   1608         pLock->locktype = SHARED_LOCK;
  1609   1609       }else{
  1610   1610         rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
  1611   1611       }
  1612   1612     }
  1613   1613     if( locktype==NO_LOCK ){
  1614   1614       struct openCnt *pOpen;
................................................................................
  1618   1618       ** the lock.
  1619   1619       */
  1620   1620       pLock->cnt--;
  1621   1621       if( pLock->cnt==0 ){
  1622   1622         lock.l_type = F_UNLCK;
  1623   1623         lock.l_whence = SEEK_SET;
  1624   1624         lock.l_start = lock.l_len = 0L;
  1625         -      if( fcntl(pFile->h, F_SETLK, &lock)==0 ){
         1625  +      if( fcntl(pFile->h, F_SETLK, &lock)!=(-1) ){
  1626   1626           pLock->locktype = NO_LOCK;
  1627   1627         }else{
  1628   1628           rc = SQLITE_IOERR_UNLOCK;  /* This should never happen */
  1629   1629         }
  1630   1630       }
  1631   1631   
  1632   1632       /* Decrement the count of locks against this same file.  When the