Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Miscellaneous cleanup of OFD logic. Add an #if 0 to disable the use of OFD logic, temporarily, until I can get it to actually work. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | ofd-locks |
Files: | files | file ages | folders |
SHA3-256: |
d849ade396d2dda4ed18f8e44d19ab21 |
User & Date: | drh 2018-06-19 17:19:46.493 |
Context
2018-06-19
| ||
19:01 | OFD locks are now mostly working, but need additional tests. (check-in: 4f1fb5c94b user: drh tags: ofd-locks) | |
17:19 | Miscellaneous cleanup of OFD logic. Add an #if 0 to disable the use of OFD logic, temporarily, until I can get it to actually work. (check-in: d849ade396 user: drh tags: ofd-locks) | |
13:45 | Initial attempt to get SQLite working with OFD locks on Linux. The code here does not function correctly. This is an incremental check-in for a work in progress. (check-in: 148f8dec9a user: drh tags: ofd-locks) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | #define IS_LOCK_ERROR(x) ((x != SQLITE_OK) && (x != SQLITE_BUSY)) /* ** Are OFD locks supported? */ #if defined(F_OFD_SETLK) && defined(F_OFD_GETLK) # define HAVE_OFD_LOCKS 1 #else # define HAVE_OFD_LOCKS 0 # define F_OFD_SETLK 0 /* Fake value so we can use the identifier */ # define F_OFD_GETLK 0 /* Fake value so we can use the identifier */ #endif /* Forward references */ typedef struct unixShm unixShm; /* Connection shared memory */ typedef struct unixShmNode unixShmNode; /* Shared memory instance */ | > > > > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | #define IS_LOCK_ERROR(x) ((x != SQLITE_OK) && (x != SQLITE_BUSY)) /* ** Are OFD locks supported? */ #if defined(F_OFD_SETLK) && defined(F_OFD_GETLK) # define HAVE_OFD_LOCKS 1 # define UsesOfd(F) ((F)->eGetLk==F_OFD_GETLK) # define UsesOldStylePosixLocks(F) ((F)->eGetLk==F_GETLK) #else # define HAVE_OFD_LOCKS 0 # define UsesOfd(F) 0 # define UsesOldStylePosixLocks(F) 1 # define F_OFD_SETLK 0 /* Fake value so we can use the identifier */ # define F_OFD_GETLK 0 /* Fake value so we can use the identifier */ #endif /* Forward references */ typedef struct unixShm unixShm; /* Connection shared memory */ typedef struct unixShmNode unixShmNode; /* Shared memory instance */ |
︙ | ︙ | |||
760 761 762 763 764 765 766 767 768 769 770 771 772 773 | char *zOpName, *zType; int s; int savedErrno; if( op==F_GETLK || op==F_OFD_GETLK ){ zOpName = "GETLK"; }else if( op==F_SETLK || op==F_OFD_SETLK ){ zOpName = "SETLK"; }else{ s = osFcntl(fd, op, p); sqlite3DebugPrintf("fcntl unknown %d %d %d\n", fd, op, s); return s; } if( p->l_type==F_RDLCK ){ zType = "RDLCK"; | > > > > > > | 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | char *zOpName, *zType; int s; int savedErrno; if( op==F_GETLK || op==F_OFD_GETLK ){ zOpName = "GETLK"; }else if( op==F_SETLK || op==F_OFD_SETLK ){ zOpName = "SETLK"; #if HAVE_OFD_LOCKS }else if( op==F_OFD_GETLK ){ zOpName = "OFD_GETLK"; }else if( op==F_OFD_SETLK ){ zOpName = "OFD_SETLK"; #endif }else{ s = osFcntl(fd, op, p); sqlite3DebugPrintf("fcntl unknown %d %d %d\n", fd, op, s); return s; } if( p->l_type==F_RDLCK ){ zType = "RDLCK"; |
︙ | ︙ | |||
786 787 788 789 790 791 792 | (int)p->l_pid, s); if( s==(-1) && (op==F_SETLK || op==F_OFD_SETLK) && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){ struct flock l2; l2 = *p; | | | 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 | (int)p->l_pid, s); if( s==(-1) && (op==F_SETLK || op==F_OFD_SETLK) && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){ struct flock l2; l2 = *p; osFcntl(fd, op==F_SETLK ? F_GETLK : F_OFD_GETLK, &l2); if( l2.l_type==F_RDLCK ){ zType = "RDLCK"; }else if( l2.l_type==F_WRLCK ){ zType = "WRLCK"; }else if( l2.l_type==F_UNLCK ){ zType = "UNLCK"; }else{ |
︙ | ︙ | |||
1698 1699 1700 1701 1702 1703 1704 | } /* If a SHARED lock is requested, and some thread using this PID already ** has a SHARED or RESERVED lock, then increment reference counts and ** return SQLITE_OK. */ if( eFileLock==SHARED_LOCK | | < | 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 | } /* If a SHARED lock is requested, and some thread using this PID already ** has a SHARED or RESERVED lock, then increment reference counts and ** return SQLITE_OK. */ if( eFileLock==SHARED_LOCK && UsesOldStylePosixLocks(pFile) && (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){ assert( eFileLock==SHARED_LOCK ); assert( pFile->eFileLock==0 ); assert( pInode->nShared>0 ); pFile->eFileLock = SHARED_LOCK; pInode->nShared++; pInode->nLock++; goto end_lock; } /* 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. */ lock.l_len = 1L; lock.l_whence = SEEK_SET; |
︙ | ︙ | |||
5459 5460 5461 5462 5463 5464 5465 | /* No locking occurs in temporary files */ assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 ); OSTRACE(("OPEN %-3d %s\n", h, zFilename)); pNew->h = h; pNew->eSetLk = F_SETLK; pNew->eGetLk = F_GETLK; | | | 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 | /* No locking occurs in temporary files */ assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 ); OSTRACE(("OPEN %-3d %s\n", h, zFilename)); pNew->h = h; pNew->eSetLk = F_SETLK; pNew->eGetLk = F_GETLK; #if HAVE_OFD_LOCKS && 0 { struct flock lock; lock.l_whence = SEEK_SET; lock.l_start = RESERVED_BYTE; lock.l_len = 1; lock.l_type = F_WRLCK; lock.l_pid = 0; |
︙ | ︙ |