aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordan <Dan Kennedy>2024-03-21 11:37:36 +0000
committerdan <Dan Kennedy>2024-03-21 11:37:36 +0000
commitaf64a22762e068ae8926cdb3e338023cff16cbb3 (patch)
treee7a95667c2dd5c6946defe1617c42cdda12e41b7 /src/os_unix.c
parent296ae1e4673151e59593105b653e87eceae25163 (diff)
downloadsqlite-af64a22762e068ae8926cdb3e338023cff16cbb3.tar.gz
sqlite-af64a22762e068ae8926cdb3e338023cff16cbb3.zip
Have os_unix.c reuse cached file-descriptors in the case when a read-write fd is requested on a read-only file and a read-only fd returned.
FossilOrigin-Name: a678e85402af08c1e387bf30ff2205f84dd7da749755da565d70f831c007a3d9
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 4663c22d9..9e7ba05d6 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -6398,12 +6398,19 @@ static int unixOpen(
rc = SQLITE_READONLY_DIRECTORY;
}else if( errno!=EISDIR && isReadWrite ){
/* Failed to open the file for read/write access. Try read-only. */
+ UnixUnusedFd *pReadonly = 0;
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT);
flags |= SQLITE_OPEN_READONLY;
openFlags |= O_RDONLY;
isReadonly = 1;
- fd = robust_open(zName, openFlags, openMode);
+ pReadonly = findReusableFd(zName, flags);
+ if( pReadonly ){
+ fd = pReadonly->fd;
+ sqlite3_free(pReadonly);
+ }else{
+ fd = robust_open(zName, openFlags, openMode);
+ }
}
}
if( fd<0 ){