mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:24:12 +08:00
mdbx: use O_DIRECT for db-copy.
Change-Id: Ib17fcdc2eba3382ed841a1e5e0a4f69f88c2491d
This commit is contained in:
parent
2b2eedbbf0
commit
bf0e0382fc
23
src/osal.c
23
src/osal.c
@ -530,16 +530,27 @@ int mdbx_openfile(const char *pathname, int flags, mode_t mode,
|
|||||||
(void)exclusive;
|
(void)exclusive;
|
||||||
#ifdef O_CLOEXEC
|
#ifdef O_CLOEXEC
|
||||||
flags |= O_CLOEXEC;
|
flags |= O_CLOEXEC;
|
||||||
#endif
|
#endif /* O_CLOEXEC */
|
||||||
*fd = open(pathname, flags, mode);
|
*fd = open(pathname, flags, mode);
|
||||||
if (*fd < 0)
|
if (*fd < 0)
|
||||||
return errno;
|
return errno;
|
||||||
#if defined(FD_CLOEXEC) && defined(F_GETFD)
|
|
||||||
flags = fcntl(*fd, F_GETFD);
|
#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC)
|
||||||
if (flags >= 0)
|
int fd_flags = fcntl(*fd, F_GETFD);
|
||||||
(void)fcntl(*fd, F_SETFD, flags | FD_CLOEXEC);
|
if (fd_flags != -1)
|
||||||
#endif
|
(void)fcntl(*fd, F_SETFD, fd_flags | FD_CLOEXEC);
|
||||||
|
#endif /* FD_CLOEXEC && !O_CLOEXEC */
|
||||||
|
|
||||||
|
if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) {
|
||||||
|
/* assume for MDBX_env_copy() and friends output */
|
||||||
|
#if defined(O_DIRECT)
|
||||||
|
int fd_flags = fcntl(*fd, F_GETFD);
|
||||||
|
if (fd_flags != -1)
|
||||||
|
(void)fcntl(*fd, F_SETFL, fd_flags | O_DIRECT);
|
||||||
|
#endif /* O_DIRECT */
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user