mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:34:13 +08:00
mdbx-windows: исправление минорных предупреждений MingGW.
This commit is contained in:
parent
987509f90f
commit
652ca2b5cb
@ -112,11 +112,10 @@ static
|
|||||||
#define LCK_WAITFOR 0
|
#define LCK_WAITFOR 0
|
||||||
#define LCK_DONTWAIT LOCKFILE_FAIL_IMMEDIATELY
|
#define LCK_DONTWAIT LOCKFILE_FAIL_IMMEDIATELY
|
||||||
|
|
||||||
static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags,
|
static int flock_with_event(HANDLE fd, HANDLE event, unsigned flags,
|
||||||
uint64_t offset, size_t bytes) {
|
size_t offset, size_t bytes) {
|
||||||
TRACE("lock>>: fd %p, event %p, flags 0x%x offset %" PRId64 ", bytes %" PRId64
|
TRACE("lock>>: fd %p, event %p, flags 0x%x offset %zu, bytes %zu >>", fd,
|
||||||
" >>",
|
event, flags, offset, bytes);
|
||||||
fd, event, flags, offset, bytes);
|
|
||||||
OVERLAPPED ov;
|
OVERLAPPED ov;
|
||||||
ov.Internal = 0;
|
ov.Internal = 0;
|
||||||
ov.InternalHigh = 0;
|
ov.InternalHigh = 0;
|
||||||
@ -124,9 +123,8 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags,
|
|||||||
ov.Offset = (DWORD)offset;
|
ov.Offset = (DWORD)offset;
|
||||||
ov.OffsetHigh = HIGH_DWORD(offset);
|
ov.OffsetHigh = HIGH_DWORD(offset);
|
||||||
if (LockFileEx(fd, flags, 0, (DWORD)bytes, HIGH_DWORD(bytes), &ov)) {
|
if (LockFileEx(fd, flags, 0, (DWORD)bytes, HIGH_DWORD(bytes), &ov)) {
|
||||||
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64
|
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << %s", fd,
|
||||||
", bytes %" PRId64 " << %s",
|
event, flags, offset, bytes, "done");
|
||||||
fd, event, flags, offset, bytes, "done");
|
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +132,7 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags,
|
|||||||
if (rc == ERROR_IO_PENDING) {
|
if (rc == ERROR_IO_PENDING) {
|
||||||
if (event) {
|
if (event) {
|
||||||
if (GetOverlappedResult(fd, &ov, &rc, true)) {
|
if (GetOverlappedResult(fd, &ov, &rc, true)) {
|
||||||
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64
|
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << %s",
|
||||||
", bytes %" PRId64 " << %s",
|
|
||||||
fd, event, flags, offset, bytes, "overlapped-done");
|
fd, event, flags, offset, bytes, "overlapped-done");
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -143,25 +140,24 @@ static int flock_with_event(HANDLE fd, HANDLE event, DWORD flags,
|
|||||||
} else
|
} else
|
||||||
CancelIo(fd);
|
CancelIo(fd);
|
||||||
}
|
}
|
||||||
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %" PRId64 ", bytes %" PRId64
|
TRACE("lock<<: fd %p, event %p, flags 0x%x offset %zu, bytes %zu << err %d",
|
||||||
" << err %d",
|
fd, event, flags, offset, bytes, (int)rc);
|
||||||
fd, event, flags, offset, bytes, rc);
|
|
||||||
return (int)rc;
|
return (int)rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline int flock(HANDLE fd, DWORD flags, uint64_t offset,
|
static __inline int flock(HANDLE fd, unsigned flags, size_t offset,
|
||||||
size_t bytes) {
|
size_t bytes) {
|
||||||
return flock_with_event(fd, 0, flags, offset, bytes);
|
return flock_with_event(fd, 0, flags, offset, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline int flock_data(const MDBX_env *env, DWORD flags,
|
static __inline int flock_data(const MDBX_env *env, unsigned flags,
|
||||||
uint64_t offset, size_t bytes) {
|
size_t offset, size_t bytes) {
|
||||||
return flock_with_event(env->me_fd4data, env->me_data_lock_event, flags,
|
return flock_with_event(env->me_fd4data, env->me_data_lock_event, flags,
|
||||||
offset, bytes);
|
offset, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int funlock(mdbx_filehandle_t fd, uint64_t offset, size_t bytes) {
|
static int funlock(mdbx_filehandle_t fd, size_t offset, size_t bytes) {
|
||||||
TRACE("unlock: fd %p, offset %" PRId64 ", bytes %" PRId64, fd, offset, bytes);
|
TRACE("unlock: fd %p, offset %zu, bytes %zu", fd, offset, bytes);
|
||||||
return UnlockFile(fd, (DWORD)offset, HIGH_DWORD(offset), (DWORD)bytes,
|
return UnlockFile(fd, (DWORD)offset, HIGH_DWORD(offset), (DWORD)bytes,
|
||||||
HIGH_DWORD(bytes))
|
HIGH_DWORD(bytes))
|
||||||
? MDBX_SUCCESS
|
? MDBX_SUCCESS
|
||||||
|
37
src/osal.c
37
src/osal.c
@ -853,9 +853,10 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
if (unlikely(r.err != ERROR_IO_PENDING)) {
|
if (unlikely(r.err != ERROR_IO_PENDING)) {
|
||||||
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"WriteFileGather", ior->fd, item, item - ior->pool,
|
"WriteFileGather", ior->fd, __Wpedantic_format_voidptr(item),
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
|
r.err);
|
||||||
goto bailout_rc;
|
goto bailout_rc;
|
||||||
}
|
}
|
||||||
assert(wait_for > ior->event_pool + ior->event_stack);
|
assert(wait_for > ior->event_pool + ior->event_stack);
|
||||||
@ -874,9 +875,10 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
default:
|
default:
|
||||||
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"WriteFileEx", ior->fd, item, item - ior->pool,
|
"WriteFileEx", ior->fd, __Wpedantic_format_voidptr(item),
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
|
r.err);
|
||||||
goto bailout_rc;
|
goto bailout_rc;
|
||||||
case ERROR_NOT_FOUND:
|
case ERROR_NOT_FOUND:
|
||||||
case ERROR_USER_MAPPED_FILE:
|
case ERROR_USER_MAPPED_FILE:
|
||||||
@ -884,9 +886,10 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
WARNING(
|
WARNING(
|
||||||
"%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
"%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"WriteFileEx", ior->fd, item, item - ior->pool,
|
"WriteFileEx", ior->fd, __Wpedantic_format_voidptr(item),
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
|
r.err);
|
||||||
SleepEx(0, true);
|
SleepEx(0, true);
|
||||||
goto retry;
|
goto retry;
|
||||||
case ERROR_INVALID_USER_BUFFER:
|
case ERROR_INVALID_USER_BUFFER:
|
||||||
@ -906,9 +909,10 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
r.err = (int)GetLastError();
|
r.err = (int)GetLastError();
|
||||||
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"WriteFile", ior->fd, item, item - ior->pool,
|
"WriteFile", ior->fd, __Wpedantic_format_voidptr(item),
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
item - ior->pool, ((MDBX_page *)item->single.iov_base)->mp_pgno,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
|
r.err);
|
||||||
goto bailout_rc;
|
goto bailout_rc;
|
||||||
} else if (unlikely(written != bytes)) {
|
} else if (unlikely(written != bytes)) {
|
||||||
r.err = ERROR_WRITE_FAULT;
|
r.err = ERROR_WRITE_FAULT;
|
||||||
@ -973,10 +977,11 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
!GetOverlappedResult(ior->fd, &item->ov, &written, true))) {
|
!GetOverlappedResult(ior->fd, &item->ov, &written, true))) {
|
||||||
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"GetOverlappedResult", item, item - ior->pool,
|
"GetOverlappedResult", __Wpedantic_format_voidptr(item),
|
||||||
|
item - ior->pool,
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
GetLastError());
|
(int)GetLastError());
|
||||||
goto bailout_geterr;
|
goto bailout_geterr;
|
||||||
}
|
}
|
||||||
assert(MDBX_SUCCESS == item->ov.Internal);
|
assert(MDBX_SUCCESS == item->ov.Internal);
|
||||||
@ -994,10 +999,10 @@ osal_ioring_write(osal_ioring_t *ior) {
|
|||||||
r.err = (int)GetLastError();
|
r.err = (int)GetLastError();
|
||||||
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
||||||
", err %d",
|
", err %d",
|
||||||
"Result", item, item - ior->pool,
|
"Result", __Wpedantic_format_voidptr(item), item - ior->pool,
|
||||||
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
((MDBX_page *)item->single.iov_base)->mp_pgno, bytes,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
GetLastError());
|
(int)GetLastError());
|
||||||
goto bailout_rc;
|
goto bailout_rc;
|
||||||
}
|
}
|
||||||
if (unlikely(item->ov.InternalHigh != bytes)) {
|
if (unlikely(item->ov.InternalHigh != bytes)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user