mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-31 11:18:21 +08:00
mdbx-windows: исправление падения при логировании ошибки WriteFileGather()
.
This commit is contained in:
parent
7dee88e27f
commit
c46270ec56
55
src/osal.c
55
src/osal.c
@ -872,12 +872,12 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
} else {
|
} else {
|
||||||
r.err = (int)GetLastError();
|
r.err = (int)GetLastError();
|
||||||
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
|
void *data = Ptr64ToPtr(item->sgv[0].Buffer);
|
||||||
", err %d",
|
ERROR("%s: fd %p, item %p (%zu), addr %p pgno %u, bytes %zu,"
|
||||||
|
" offset %" PRId64 ", err %d",
|
||||||
"WriteFileGather", fd, __Wpedantic_format_voidptr(item),
|
"WriteFileGather", fd, __Wpedantic_format_voidptr(item),
|
||||||
item - ior->pool, ((page_t *)item->single.iov_base)->pgno,
|
item - ior->pool, data, ((page_t *)data)->pgno, bytes,
|
||||||
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
||||||
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);
|
||||||
@ -894,22 +894,23 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
r.err = (int)GetLastError();
|
r.err = (int)GetLastError();
|
||||||
switch (r.err) {
|
switch (r.err) {
|
||||||
default:
|
default:
|
||||||
ERROR("%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: fd %p, item %p (%zu), addr %p pgno %u, bytes %zu,"
|
||||||
", err %d",
|
" offset %" PRId64 ", err %d",
|
||||||
"WriteFileEx", fd, __Wpedantic_format_voidptr(item),
|
"WriteFileEx", fd, __Wpedantic_format_voidptr(item),
|
||||||
item - ior->pool, ((page_t *)item->single.iov_base)->pgno,
|
item - ior->pool, item->single.iov_base,
|
||||||
bytes, item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
((page_t *)item->single.iov_base)->pgno, bytes,
|
||||||
r.err);
|
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:
|
||||||
case ERROR_LOCK_VIOLATION:
|
case ERROR_LOCK_VIOLATION:
|
||||||
WARNING(
|
WARNING("%s: fd %p, item %p (%zu), addr %p pgno %u, bytes %zu,"
|
||||||
"%s: fd %p, item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
" offset %" PRId64 ", err %d",
|
||||||
", err %d",
|
"WriteFileEx", fd, __Wpedantic_format_voidptr(item),
|
||||||
"WriteFileEx", fd, __Wpedantic_format_voidptr(item),
|
item - ior->pool, item->single.iov_base,
|
||||||
item - ior->pool, ((page_t *)item->single.iov_base)->pgno, bytes,
|
((page_t *)item->single.iov_base)->pgno, bytes,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
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:
|
||||||
@ -927,10 +928,11 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
if (!WriteFile(fd, item->single.iov_base, (DWORD)bytes, &written,
|
if (!WriteFile(fd, item->single.iov_base, (DWORD)bytes, &written,
|
||||||
&item->ov)) {
|
&item->ov)) {
|
||||||
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), addr %p pgno %u, bytes %zu,"
|
||||||
", err %d",
|
" offset %" PRId64 ", err %d",
|
||||||
"WriteFile", fd, __Wpedantic_format_voidptr(item),
|
"WriteFile", fd, __Wpedantic_format_voidptr(item),
|
||||||
item - ior->pool, ((page_t *)item->single.iov_base)->pgno, bytes,
|
item - ior->pool, item->single.iov_base,
|
||||||
|
((page_t *)item->single.iov_base)->pgno, bytes,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32), r.err);
|
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)) {
|
||||||
@ -984,7 +986,9 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
assert(ior->async_waiting == ior->async_completed);
|
assert(ior->async_waiting == ior->async_completed);
|
||||||
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
for (ior_item_t *item = ior->pool; item <= ior->last;) {
|
||||||
size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag;
|
size_t i = 1, bytes = item->single.iov_len - ior_WriteFile_flag;
|
||||||
|
void *data = item->single.iov_base;
|
||||||
if (bytes & ior_WriteFile_flag) {
|
if (bytes & ior_WriteFile_flag) {
|
||||||
|
data = Ptr64ToPtr(item->sgv[0].Buffer);
|
||||||
bytes = ior->pagesize;
|
bytes = ior->pagesize;
|
||||||
/* Zap: Reading invalid data from 'item->sgv' */
|
/* Zap: Reading invalid data from 'item->sgv' */
|
||||||
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
MDBX_SUPPRESS_GOOFY_MSVC_ANALYZER(6385);
|
||||||
@ -995,11 +999,10 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
if (!HasOverlappedIoCompleted(&item->ov)) {
|
if (!HasOverlappedIoCompleted(&item->ov)) {
|
||||||
DWORD written = 0;
|
DWORD written = 0;
|
||||||
if (unlikely(!GetOverlappedResult(fd, &item->ov, &written, true))) {
|
if (unlikely(!GetOverlappedResult(fd, &item->ov, &written, true))) {
|
||||||
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: item %p (%zu), addr %p pgno %u, bytes %zu,"
|
||||||
", err %d",
|
" offset %" PRId64 ", err %d",
|
||||||
"GetOverlappedResult", __Wpedantic_format_voidptr(item),
|
"GetOverlappedResult", __Wpedantic_format_voidptr(item),
|
||||||
item - ior->pool, ((page_t *)item->single.iov_base)->pgno,
|
item - ior->pool, data, ((page_t *)data)->pgno, bytes,
|
||||||
bytes,
|
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
(int)GetLastError());
|
(int)GetLastError());
|
||||||
goto bailout_geterr;
|
goto bailout_geterr;
|
||||||
@ -1017,10 +1020,10 @@ osal_ioring_write(osal_ioring_t *ior, mdbx_filehandle_t fd) {
|
|||||||
if ((r.err & 0x80000000) &&
|
if ((r.err & 0x80000000) &&
|
||||||
GetOverlappedResult(nullptr, &item->ov, &written, true))
|
GetOverlappedResult(nullptr, &item->ov, &written, true))
|
||||||
r.err = (int)GetLastError();
|
r.err = (int)GetLastError();
|
||||||
ERROR("%s: item %p (%zu), pgno %u, bytes %zu, offset %" PRId64
|
ERROR("%s: item %p (%zu), addr %p pgno %u, bytes %zu,"
|
||||||
", err %d",
|
" offset %" PRId64 ", err %d",
|
||||||
"Result", __Wpedantic_format_voidptr(item), item - ior->pool,
|
"Result", __Wpedantic_format_voidptr(item), item - ior->pool,
|
||||||
((page_t *)item->single.iov_base)->pgno, bytes,
|
data, ((page_t *)data)->pgno, bytes,
|
||||||
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
item->ov.Offset + ((uint64_t)item->ov.OffsetHigh << 32),
|
||||||
(int)GetLastError());
|
(int)GetLastError());
|
||||||
goto bailout_rc;
|
goto bailout_rc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user