Skip to content

Commit 0b61924

Browse files
committed
lmdb: fix Windows commit offset handling past 2GiB
1 parent bd8d648 commit 0b61924

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • third_party/lmdb-rs-mintlayer/lmdb-sys/lmdb/libraries/liblmdb

third_party/lmdb-rs-mintlayer/lmdb-sys/lmdb/libraries/liblmdb/mdb.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,7 +3668,11 @@ mdb_page_flush(MDB_txn *txn, int keep)
36683668
unsigned psize = env->me_psize, j;
36693669
int i, pagecount = dl[0].mid, rc;
36703670
size_t size = 0;
3671+
#ifdef _WIN32
3672+
mdb_size_t pos = 0;
3673+
#else
36713674
off_t pos = 0;
3675+
#endif
36723676
pgno_t pgno = 0;
36733677
MDB_page *dp = NULL;
36743678
#ifdef _WIN32
@@ -3726,11 +3730,14 @@ mdb_page_flush(MDB_txn *txn, int keep)
37263730
*/
37273731
DPRINTF(("committing page %"Yu, pgno));
37283732
memset(&ov, 0, sizeof(ov));
3729-
ov.Offset = pos & 0xffffffff;
3730-
ov.OffsetHigh = pos >> 16 >> 16;
3733+
ov.Offset = (DWORD)(pos & 0xffffffffULL);
3734+
ov.OffsetHigh = (DWORD)(pos >> 32);
37313735
if (!WriteFile(env->me_fd, dp, size, NULL, &ov)) {
37323736
rc = ErrCode();
3733-
DPRINTF(("WriteFile: %d", rc));
3737+
DPRINTF((
3738+
"WriteFile: %d, pos=%"Yu", ov=(0x%08X,0x%08X), size=%"Z"u, pgno=%"Yu,
3739+
rc, pos, ov.OffsetHigh, ov.Offset, size, pgno
3740+
));
37343741
return rc;
37353742
}
37363743
#else

0 commit comments

Comments
 (0)