|
|
|
@ -2416,11 +2416,13 @@ mdb_env_read_header(MDB_env *env, MDB_meta *meta) |
|
|
|
|
MDB_pagebuf pbuf; |
|
|
|
|
MDB_page *p; |
|
|
|
|
MDB_meta *m; |
|
|
|
|
int rc, err; |
|
|
|
|
int i, rc, err; |
|
|
|
|
|
|
|
|
|
/* We don't know the page size yet, so use a minimum value.
|
|
|
|
|
* Read both meta pages so we can use the latest one. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
for (i=0; i<2; i++) { |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
if (!ReadFile(env->me_fd, &pbuf, MDB_PAGESIZE, (DWORD *)&rc, NULL) || rc == 0) |
|
|
|
|
#else |
|
|
|
@ -2456,7 +2458,19 @@ mdb_env_read_header(MDB_env *env, MDB_meta *meta) |
|
|
|
|
return MDB_VERSION_MISMATCH; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (i) { |
|
|
|
|
if (m->mm_txnid > meta->mm_txnid) |
|
|
|
|
memcpy(meta, m, sizeof(*m)); |
|
|
|
|
} else { |
|
|
|
|
memcpy(meta, m, sizeof(*m)); |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
if (SetFilePointer(env->me_fd, meta->mm_psize, NULL, FILE_BEGIN) != meta->mm_psize) |
|
|
|
|
#else |
|
|
|
|
if (lseek(env->me_fd, meta->mm_psize, SEEK_SET) != meta->mm_psize) |
|
|
|
|
#endif |
|
|
|
|
return ErrCode(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|