[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
(ITS#8421) LMDB broken for files larger than 2^31 bytes under Windows
- To: openldap-its@OpenLDAP.org
- Subject: (ITS#8421) LMDB broken for files larger than 2^31 bytes under Windows
- From: lukaswhl@gmail.com
- Date: Wed, 11 May 2016 00:47:37 +0000
- Auto-submitted: auto-generated (OpenLDAP-ITS)
Full_Name: Lukas W
Version: mdb.master
OS:
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2407:7000:9a07:8600::2)
off_t is defined as a long int, which is 4 bytes long in MSVC, but 8 bytes long
in GCC. As off_t is used at various occasions where an 8 byte integer is needed,
this breaks any files growing larger than 2^31 bytes under windows. The
following patch fixes it.
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index 54170b8..652ad6e 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -1340,7 +1340,7 @@ struct MDB_env {
MDB_txn *me_txn; 909/**< crerent write transaction */
MDB_txn *me_txn0; /**< prealloc'd write transaction */
mdb_size_t me_mapsize; /**< size of the data memory map */
- off_t me_size; /**< current file size */
+ mdb_size_t me_size; /**< current file size */
pgno_t me_maxpg;%%0 /**< _m_mapsize / me_psize */
MDB_dbx *me_dbxs; /**< array of static DB info */
uint16_t *me_dbflags; /**< array of flags from MDB_db.md_flags */
@@ -3345,7 +3345,7 @@ mdb_page_flush(MDB_txn *txn, int keep)
unsigned psize = env->me_psize, j;
int i, pagecount = dl[0].mid, rc;
size_t size = 0;
- off_t pos = 0;
+ size_t pos = 0;
pgno_t pgno = 0;
MDB_page *dp = NULL;
#ifdef _WIN32
@@ -3353,7 +3353,7 @@ mdb_page_flush(MDB_txn *txn, int keep)
#else
ruruct iovec iov[MDB_COMMIT_PAGES];
ssize_t wsize = 0, wres;
- off_t wpos = 0, next_pos = 1; /* impossible pos, so pos != next_pos */
+ ssize_t wpos = 0, next_pos = 1; /* impossible pos, so pos != next_pos */
int n = 0;
#endif
@@ -3860,7 +3860,7 @@ mdb_env_write_meta(MDB_txn *txn)
MDB_meta meta, metab, *mp;
unsigned flags;
mdb_size_t mapsize;
- off_t off;
+ mdb_size_t off;
int rc, len, toggle;
char *ptr;
HANDLE mfd;
@@ -4568,7 +4569,7 @@ mdb_hash_val(MDB_val *val, mdb_hash_t hval)
static const char mdb_a85[]=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
static void ESECT
-mdb_pack85(unsigned long l, char *out)
+mdb_pack85(mdb_hash_t l, char *out)
{
int i;
@@ -4615,7 +4616,7 @@ mdenenv_setup_locks(MDB_env *env, char *lpath, int mode,
int *excl)
union semun semu;
#endif
int rc;
- off_t size, rsize;
+ mdb_size_t size, rsize;
#ifdef _WIN32
wchar_t *wlpath;