mirror of
https://github.com/isar/libmdbx.git
synced 2025-08-23 09:04:26 +08:00
mdbx: use MDBX_EPERM
to indicate that the geometry cannot be updated instead of `MDBX_RESULT_TRUE'.
This commit is contained in:
@@ -6234,7 +6234,7 @@ bailout:
|
||||
}
|
||||
#endif /* MDBX_USE_VALGRIND */
|
||||
} else {
|
||||
if (rc != MDBX_UNABLE_EXTEND_MAPSIZE && rc != MDBX_RESULT_TRUE) {
|
||||
if (rc != MDBX_UNABLE_EXTEND_MAPSIZE && rc != MDBX_EPERM) {
|
||||
mdbx_error("failed resize datafile/mapping: "
|
||||
"present %" PRIuPTR " -> %" PRIuPTR ", "
|
||||
"limit %" PRIuPTR " -> %" PRIuPTR ", errcode %d",
|
||||
@@ -8716,7 +8716,7 @@ static int mdbx_txn_end(MDBX_txn *txn, const unsigned mode) {
|
||||
/* undo resize performed by child txn */
|
||||
rc = mdbx_mapresize_implicit(env, parent->mt_next_pgno,
|
||||
parent->mt_geo.now, parent->mt_geo.upper);
|
||||
if (rc == MDBX_RESULT_TRUE) {
|
||||
if (rc == MDBX_EPERM) {
|
||||
/* unable undo resize (it is regular for Windows),
|
||||
* therefore promote size changes from child to the parent txn */
|
||||
mdbx_warning("unable undo resize performed by child txn, promote to "
|
||||
@@ -11256,7 +11256,7 @@ static int mdbx_sync_locked(MDBX_env *env, unsigned flags,
|
||||
pending->mm_geo.now, shrink);
|
||||
rc = mdbx_mapresize_implicit(env, pending->mm_geo.next, pending->mm_geo.now,
|
||||
pending->mm_geo.upper);
|
||||
if (MDBX_IS_ERROR(rc))
|
||||
if (rc != MDBX_SUCCESS && rc != MDBX_EPERM)
|
||||
goto fail;
|
||||
mdbx_assert(env, meta_checktxnid(env, target, true));
|
||||
}
|
||||
|
@@ -1619,7 +1619,7 @@ MDBX_INTERNAL_FUNC int mdbx_mresize(const int flags, mdbx_mmap_t *map,
|
||||
* - extend read-only mapping;
|
||||
* Therefore we should unmap/map entire section. */
|
||||
if ((flags & MDBX_MRESIZE_MAY_UNMAP) == 0)
|
||||
return MDBX_RESULT_TRUE;
|
||||
return MDBX_EPERM;
|
||||
|
||||
/* Unpoisoning is required for ASAN to avoid false-positive diagnostic
|
||||
* when this memory will re-used by malloc or another mmapping.
|
||||
@@ -1729,7 +1729,7 @@ retry_mapview:;
|
||||
if (map->address && (size != map->current || limit != map->limit)) {
|
||||
/* try remap with previously size and limit,
|
||||
* but will return MDBX_UNABLE_EXTEND_MAPSIZE on success */
|
||||
rc = (limit > map->limit) ? MDBX_UNABLE_EXTEND_MAPSIZE : MDBX_RESULT_TRUE;
|
||||
rc = (limit > map->limit) ? MDBX_UNABLE_EXTEND_MAPSIZE : MDBX_EPERM;
|
||||
size = map->current;
|
||||
ReservedSize = limit = map->limit;
|
||||
goto retry_file_and_section;
|
||||
@@ -1753,8 +1753,7 @@ retry_mapview:;
|
||||
if (flags & MDBX_RDONLY) {
|
||||
map->current = (map->filesize > limit) ? limit : (size_t)map->filesize;
|
||||
if (map->current != size)
|
||||
rc =
|
||||
(size > map->current) ? MDBX_UNABLE_EXTEND_MAPSIZE : MDBX_RESULT_TRUE;
|
||||
rc = (size > map->current) ? MDBX_UNABLE_EXTEND_MAPSIZE : MDBX_EPERM;
|
||||
} else {
|
||||
if (map->filesize != size) {
|
||||
rc = mdbx_ftruncate(map->fd, size);
|
||||
|
Reference in New Issue
Block a user