|
|
@ -4965,31 +4965,21 @@ mdb_env_excl_lock(MDB_env *env, int *excl) |
|
|
|
* Share and Enjoy! :-) |
|
|
|
* Share and Enjoy! :-) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#define MDB_HASH_INIT ((mdb_hash_t)0xcbf29ce484222325ULL) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
|
|
|
|
/** perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
|
|
|
|
* @param[in] val value to hash |
|
|
|
* @param[in] val value to hash |
|
|
|
* @param[in] hval initial value for hash |
|
|
|
* @param[in] len length of value |
|
|
|
* @return 64 bit hash |
|
|
|
* @return 64 bit hash |
|
|
|
* |
|
|
|
|
|
|
|
* NOTE: To use the recommended 64 bit FNV-1a hash, use MDB_HASH_INIT as the |
|
|
|
|
|
|
|
* hval arg on the first call. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static mdb_hash_t |
|
|
|
static mdb_hash_t |
|
|
|
mdb_hash_val(MDB_val *val, mdb_hash_t hval) |
|
|
|
mdb_hash(const void *val, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned char *s = (unsigned char *)val->mv_data; /* unsigned string */ |
|
|
|
const unsigned char *s = (const unsigned char *) val, *end = s + len; |
|
|
|
unsigned char *end = s + val->mv_size; |
|
|
|
mdb_hash_t hval = 0xcbf29ce484222325ULL; |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* FNV-1a hash each octet of the string |
|
|
|
* FNV-1a hash each octet of the buffer |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
while (s < end) { |
|
|
|
while (s < end) { |
|
|
|
/* xor the bottom with the current octet */ |
|
|
|
hval = (hval ^ *s++) * 0x100000001b3ULL; |
|
|
|
hval ^= (mdb_hash_t)*s++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* multiply by the 64 bit FNV magic prime mod 2^64 */ |
|
|
|
|
|
|
|
hval += (hval << 1) + (hval << 4) + (hval << 5) + |
|
|
|
|
|
|
|
(hval << 7) + (hval << 8) + (hval << 40); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/* return our new hash value */ |
|
|
|
/* return our new hash value */ |
|
|
|
return hval; |
|
|
|
return hval; |
|
|
@ -5130,7 +5120,6 @@ mdb_env_setup_locks(MDB_env *env, MDB_name *fname, int mode, int *excl) |
|
|
|
DWORD nhigh; |
|
|
|
DWORD nhigh; |
|
|
|
DWORD nlow; |
|
|
|
DWORD nlow; |
|
|
|
} idbuf; |
|
|
|
} idbuf; |
|
|
|
MDB_val val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mdb_sec_inited) { |
|
|
|
if (!mdb_sec_inited) { |
|
|
|
InitializeSecurityDescriptor(&mdb_null_sd, |
|
|
|
InitializeSecurityDescriptor(&mdb_null_sd, |
|
|
@ -5145,9 +5134,7 @@ mdb_env_setup_locks(MDB_env *env, MDB_name *fname, int mode, int *excl) |
|
|
|
idbuf.volume = stbuf.dwVolumeSerialNumber; |
|
|
|
idbuf.volume = stbuf.dwVolumeSerialNumber; |
|
|
|
idbuf.nhigh = stbuf.nFileIndexHigh; |
|
|
|
idbuf.nhigh = stbuf.nFileIndexHigh; |
|
|
|
idbuf.nlow = stbuf.nFileIndexLow; |
|
|
|
idbuf.nlow = stbuf.nFileIndexLow; |
|
|
|
val.mv_data = &idbuf; |
|
|
|
env->me_txns->mti_mutexid = mdb_hash(&idbuf, sizeof(idbuf)); |
|
|
|
val.mv_size = sizeof(idbuf); |
|
|
|
|
|
|
|
env->me_txns->mti_mutexid = mdb_hash_val(&val, MDB_HASH_INIT); |
|
|
|
|
|
|
|
mdb_env_mname_init(env); |
|
|
|
mdb_env_mname_init(env); |
|
|
|
env->me_rmutex = CreateMutexA(&mdb_all_sa, FALSE, MUTEXNAME(env, 'r')); |
|
|
|
env->me_rmutex = CreateMutexA(&mdb_all_sa, FALSE, MUTEXNAME(env, 'r')); |
|
|
|
if (!env->me_rmutex) goto fail_errno; |
|
|
|
if (!env->me_rmutex) goto fail_errno; |
|
|
@ -5159,7 +5146,6 @@ mdb_env_setup_locks(MDB_env *env, MDB_name *fname, int mode, int *excl) |
|
|
|
dev_t dev; |
|
|
|
dev_t dev; |
|
|
|
ino_t ino; |
|
|
|
ino_t ino; |
|
|
|
} idbuf; |
|
|
|
} idbuf; |
|
|
|
MDB_val val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__NetBSD__) |
|
|
|
#if defined(__NetBSD__) |
|
|
|
#define MDB_SHORT_SEMNAMES 1 /* limited to 14 chars */ |
|
|
|
#define MDB_SHORT_SEMNAMES 1 /* limited to 14 chars */ |
|
|
@ -5167,9 +5153,7 @@ mdb_env_setup_locks(MDB_env *env, MDB_name *fname, int mode, int *excl) |
|
|
|
if (fstat(env->me_lfd, &stbuf)) goto fail_errno; |
|
|
|
if (fstat(env->me_lfd, &stbuf)) goto fail_errno; |
|
|
|
idbuf.dev = stbuf.st_dev; |
|
|
|
idbuf.dev = stbuf.st_dev; |
|
|
|
idbuf.ino = stbuf.st_ino; |
|
|
|
idbuf.ino = stbuf.st_ino; |
|
|
|
val.mv_data = &idbuf; |
|
|
|
env->me_txns->mti_mutexid = mdb_hash(&idbuf, sizeof(idbuf)) |
|
|
|
val.mv_size = sizeof(idbuf); |
|
|
|
|
|
|
|
env->me_txns->mti_mutexid = mdb_hash_val(&val, MDB_HASH_INIT) |
|
|
|
|
|
|
|
#ifdef MDB_SHORT_SEMNAMES |
|
|
|
#ifdef MDB_SHORT_SEMNAMES |
|
|
|
/* Max 9 base85-digits. We truncate here instead of in
|
|
|
|
/* Max 9 base85-digits. We truncate here instead of in
|
|
|
|
* mdb_env_mname_init() to keep the latter portable. |
|
|
|
* mdb_env_mname_init() to keep the latter portable. |
|
|
|