|
|
@ -2423,6 +2423,7 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
off_t off; |
|
|
|
off_t off; |
|
|
|
int rc, len, toggle; |
|
|
|
int rc, len, toggle; |
|
|
|
char *ptr; |
|
|
|
char *ptr; |
|
|
|
|
|
|
|
HANDLE mfd; |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
OVERLAPPED ov; |
|
|
|
OVERLAPPED ov; |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -2481,14 +2482,16 @@ mdb_env_write_meta(MDB_txn *txn) |
|
|
|
off += PAGEHDRSZ; |
|
|
|
off += PAGEHDRSZ; |
|
|
|
|
|
|
|
|
|
|
|
/* Write to the SYNC fd */ |
|
|
|
/* Write to the SYNC fd */ |
|
|
|
|
|
|
|
mfd = env->me_flags & (MDB_NOSYNC|MDB_NOMETASYNC) ? |
|
|
|
|
|
|
|
env->me_fd : env->me_mfd; |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
{ |
|
|
|
{ |
|
|
|
memset(&ov, 0, sizeof(ov)); |
|
|
|
memset(&ov, 0, sizeof(ov)); |
|
|
|
ov.Offset = off; |
|
|
|
ov.Offset = off; |
|
|
|
WriteFile(env->me_mfd, ptr, len, (DWORD *)&rc, &ov); |
|
|
|
WriteFile(mfd, ptr, len, (DWORD *)&rc, &ov); |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
rc = pwrite(env->me_mfd, ptr, len, off); |
|
|
|
rc = pwrite(mfd, ptr, len, off); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (rc != len) { |
|
|
|
if (rc != len) { |
|
|
|
int r2; |
|
|
|
int r2; |
|
|
@ -3221,10 +3224,12 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mode_t mode) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((rc = mdb_env_open2(env)) == MDB_SUCCESS) { |
|
|
|
if ((rc = mdb_env_open2(env)) == MDB_SUCCESS) { |
|
|
|
if (flags & (MDB_RDONLY|MDB_NOSYNC|MDB_NOMETASYNC|MDB_WRITEMAP)) { |
|
|
|
if (flags & (MDB_RDONLY|MDB_WRITEMAP)) { |
|
|
|
env->me_mfd = env->me_fd; |
|
|
|
env->me_mfd = env->me_fd; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* synchronous fd for meta writes */ |
|
|
|
/* Synchronous fd for meta writes. Needed even with
|
|
|
|
|
|
|
|
* MDB_NOSYNC/MDB_NOMETASYNC, in case these get reset. |
|
|
|
|
|
|
|
*/ |
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
env->me_mfd = CreateFile(dpath, oflags, |
|
|
|
env->me_mfd = CreateFile(dpath, oflags, |
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, len, |
|
|
|
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, len, |
|
|
|