From: Howard Chu Date: Sat, 2 Jan 2016 12:19:42 +0000 (+0000) Subject: Fixups for env_copy with large files X-Git-Tag: LMDB_0.9.18~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=05709ce6fa4ef5952116b5e8937ce268c73afdcf;p=openldap Fixups for env_copy with large files wsize was being truncated to 32bits on Windows. Only try to write 1GB at a time on Windows64; larger writes fail with ERROR_WORKING_SET_QUOTA. --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index d2cea63670..ff0d883e35 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -1271,7 +1271,7 @@ typedef struct MDB_ntxn { #endif /** max bytes to write in one call */ -#define MAX_WRITE (0x80000000U >> (sizeof(ssize_t) == 4)) +#define MAX_WRITE (0x40000000U >> (sizeof(ssize_t) == 4)) /** Check \b txn and \b dbi arguments to a function */ #define TXN_DBI_EXIST(txn, dbi, validity) \ @@ -9157,7 +9157,7 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd) MDB_txn *txn = NULL; mdb_mutexref_t wmutex = NULL; int rc; - size_t wsize; + size_t wsize, w3; char *ptr; #ifdef _WIN32 DWORD len, w2; @@ -9216,15 +9216,15 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd) if (rc) goto leave; - w2 = txn->mt_next_pgno * env->me_psize; + w3 = txn->mt_next_pgno * env->me_psize; { size_t fsize = 0; if ((rc = mdb_fsize(env->me_fd, &fsize))) goto leave; - if (w2 > fsize) - w2 = fsize; + if (w3 > fsize) + w3 = fsize; } - wsize = w2 - wsize; + wsize = w3 - wsize; while (wsize > 0) { if (wsize > MAX_WRITE) w2 = MAX_WRITE;