|
|
@ -163,6 +163,7 @@ |
|
|
|
#define GET_PAGESIZE(x) {SYSTEM_INFO si; GetSystemInfo(&si); (x) = si.dwPageSize;} |
|
|
|
#define GET_PAGESIZE(x) {SYSTEM_INFO si; GetSystemInfo(&si); (x) = si.dwPageSize;} |
|
|
|
#define close(fd) (CloseHandle(fd) ? 0 : -1) |
|
|
|
#define close(fd) (CloseHandle(fd) ? 0 : -1) |
|
|
|
#define munmap(ptr,len) UnmapViewOfFile(ptr) |
|
|
|
#define munmap(ptr,len) UnmapViewOfFile(ptr) |
|
|
|
|
|
|
|
#define unlink(file) DeleteFile(file) |
|
|
|
#ifdef PROCESS_QUERY_LIMITED_INFORMATION |
|
|
|
#ifdef PROCESS_QUERY_LIMITED_INFORMATION |
|
|
|
#define MDB_PROCESS_QUERY_LIMITED_INFORMATION PROCESS_QUERY_LIMITED_INFORMATION |
|
|
|
#define MDB_PROCESS_QUERY_LIMITED_INFORMATION PROCESS_QUERY_LIMITED_INFORMATION |
|
|
|
#else |
|
|
|
#else |
|
|
@ -3851,7 +3852,7 @@ fail: |
|
|
|
int |
|
|
|
int |
|
|
|
mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode) |
|
|
|
mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int oflags, rc, len, excl = -1; |
|
|
|
int oflags, rc, len, excl = -1, rmlock = 0; |
|
|
|
char *lpath, *dpath; |
|
|
|
char *lpath, *dpath; |
|
|
|
|
|
|
|
|
|
|
|
if (env->me_fd!=INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS))) |
|
|
|
if (env->me_fd!=INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS))) |
|
|
@ -3903,6 +3904,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode |
|
|
|
goto leave; |
|
|
|
goto leave; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
#define MDB_NO_SUCH_FILE ERROR_FILE_NOT_FOUND |
|
|
|
if (F_ISSET(flags, MDB_RDONLY)) { |
|
|
|
if (F_ISSET(flags, MDB_RDONLY)) { |
|
|
|
oflags = GENERIC_READ; |
|
|
|
oflags = GENERIC_READ; |
|
|
|
len = OPEN_EXISTING; |
|
|
|
len = OPEN_EXISTING; |
|
|
@ -3914,6 +3916,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode |
|
|
|
env->me_fd = CreateFile(dpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE, |
|
|
|
env->me_fd = CreateFile(dpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE, |
|
|
|
NULL, len, mode, NULL); |
|
|
|
NULL, len, mode, NULL); |
|
|
|
#else |
|
|
|
#else |
|
|
|
|
|
|
|
#define MDB_NO_SUCH_FILE ENOENT |
|
|
|
if (F_ISSET(flags, MDB_RDONLY)) |
|
|
|
if (F_ISSET(flags, MDB_RDONLY)) |
|
|
|
oflags = O_RDONLY; |
|
|
|
oflags = O_RDONLY; |
|
|
|
else |
|
|
|
else |
|
|
@ -3923,6 +3926,8 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (env->me_fd == INVALID_HANDLE_VALUE) { |
|
|
|
if (env->me_fd == INVALID_HANDLE_VALUE) { |
|
|
|
rc = ErrCode(); |
|
|
|
rc = ErrCode(); |
|
|
|
|
|
|
|
if (F_ISSET(flags, MDB_RDONLY) && rc == MDB_NO_SUCH_FILE)
|
|
|
|
|
|
|
|
rmlock = 1; |
|
|
|
goto leave; |
|
|
|
goto leave; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3954,6 +3959,8 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode |
|
|
|
leave: |
|
|
|
leave: |
|
|
|
if (rc) { |
|
|
|
if (rc) { |
|
|
|
mdb_env_close0(env, excl); |
|
|
|
mdb_env_close0(env, excl); |
|
|
|
|
|
|
|
if (rmlock && excl) |
|
|
|
|
|
|
|
unlink(lpath); |
|
|
|
} |
|
|
|
} |
|
|
|
free(lpath); |
|
|
|
free(lpath); |
|
|
|
return rc; |
|
|
|
return rc; |
|
|
|