Fix mdb_copy & co when MDB pagesize < OS pagesize

vl32
Hallvard Furuseth 11 years ago committed by Howard Chu
parent 1b08d8e503
commit 6cb1166635
  1. 6
      libraries/liblmdb/mdb.c

@ -8410,13 +8410,13 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd)
#ifdef _WIN32 #ifdef _WIN32
my.mc_mutex = CreateMutex(NULL, FALSE, NULL); my.mc_mutex = CreateMutex(NULL, FALSE, NULL);
my.mc_cond = CreateEvent(NULL, FALSE, FALSE, NULL); my.mc_cond = CreateEvent(NULL, FALSE, FALSE, NULL);
my.mc_wbuf[0] = _aligned_malloc(MDB_WBUF*2, env->me_psize); my.mc_wbuf[0] = _aligned_malloc(MDB_WBUF*2, env->me_os_psize);
if (my.mc_wbuf[0] == NULL) if (my.mc_wbuf[0] == NULL)
return errno; return errno;
#else #else
pthread_mutex_init(&my.mc_mutex, NULL); pthread_mutex_init(&my.mc_mutex, NULL);
pthread_cond_init(&my.mc_cond, NULL); pthread_cond_init(&my.mc_cond, NULL);
rc = posix_memalign((void **)&my.mc_wbuf[0], env->me_psize, MDB_WBUF*2); rc = posix_memalign((void **)&my.mc_wbuf[0], env->me_os_psize, MDB_WBUF*2);
if (rc) if (rc)
return rc; return rc;
#endif #endif
@ -8654,6 +8654,7 @@ mdb_env_copy2(MDB_env *env, const char *path, unsigned int flags)
goto leave; goto leave;
} }
if (env->me_psize >= env->me_os_psize) {
#ifdef O_DIRECT #ifdef O_DIRECT
/* Set O_DIRECT if the file system supports it */ /* Set O_DIRECT if the file system supports it */
if ((rc = fcntl(newfd, F_GETFL)) != -1) if ((rc = fcntl(newfd, F_GETFL)) != -1)
@ -8666,6 +8667,7 @@ mdb_env_copy2(MDB_env *env, const char *path, unsigned int flags)
goto leave; goto leave;
} }
#endif #endif
}
rc = mdb_env_copyfd2(env, newfd, flags); rc = mdb_env_copyfd2(env, newfd, flags);

Loading…
Cancel
Save