@@ -73,3 +73,3 @@ /** @file midl.c | ||
| } else { | ||
| return cursor; | ||
| return x; | ||
| } | ||
@@ -76,0 +76,0 @@ } |
+9
-9
| { | ||
| "name": "lmdb", | ||
| "author": "Kris Zyp", | ||
| "version": "3.5.3", | ||
| "version": "3.5.4", | ||
| "description": "Simple, efficient, scalable, high-performance LMDB interface", | ||
@@ -75,3 +75,3 @@ "license": "MIT", | ||
| "test": "mocha test/**.test.js --expose-gc --recursive", | ||
| "deno-test": "deno run --allow-ffi --allow-write --allow-read --allow-env --allow-net --allow-import --allow-sys test/deno.ts", | ||
| "deno-test": "deno run --allow-ffi --allow-write --allow-read --allow-run --allow-env --allow-net --allow-import --allow-sys test/deno.ts", | ||
| "test2": "mocha test/performance.js -u tdd", | ||
@@ -117,10 +117,10 @@ "test:types": "tsd", | ||
| "optionalDependencies": { | ||
| "@lmdb/lmdb-darwin-arm64": "3.5.3", | ||
| "@lmdb/lmdb-darwin-x64": "3.5.3", | ||
| "@lmdb/lmdb-linux-arm": "3.5.3", | ||
| "@lmdb/lmdb-linux-arm64": "3.5.3", | ||
| "@lmdb/lmdb-linux-x64": "3.5.3", | ||
| "@lmdb/lmdb-win32-arm64": "3.5.3", | ||
| "@lmdb/lmdb-win32-x64": "3.5.3" | ||
| "@lmdb/lmdb-darwin-arm64": "3.5.4", | ||
| "@lmdb/lmdb-darwin-x64": "3.5.4", | ||
| "@lmdb/lmdb-linux-arm": "3.5.4", | ||
| "@lmdb/lmdb-linux-arm64": "3.5.4", | ||
| "@lmdb/lmdb-linux-x64": "3.5.4", | ||
| "@lmdb/lmdb-win32-arm64": "3.5.4", | ||
| "@lmdb/lmdb-win32-x64": "3.5.4" | ||
| } | ||
| } |
+22
-10
@@ -51,7 +51,9 @@ #include "lmdb-js.h" | ||
| void EnvWrap::cleanupEnvWraps(void* data) { | ||
| if (openEnvWraps) | ||
| delete openEnvWraps; | ||
| else | ||
| fprintf(stderr, "How do we end up cleanup env wraps that don't exist?\n"); | ||
| openEnvWraps = nullptr; | ||
| // The cleanup-hook arg is the identity of the bookkeeping allocation for | ||
| // this thread's open env list. | ||
| auto* envWraps = (std::vector<EnvWrap*>*) data; | ||
| delete envWraps; | ||
| if (openEnvWraps == envWraps) { | ||
| openEnvWraps = nullptr; | ||
| } | ||
| } | ||
@@ -74,2 +76,3 @@ EnvWrap::EnvWrap(const CallbackInfo& info) : ObjectWrap<EnvWrap>(info) { | ||
| this->hasWrites = false; | ||
| this->cleanupHookRegistered = false; | ||
| this->lastReaderCheck = 0; | ||
@@ -251,3 +254,5 @@ this->writingLock = new pthread_mutex_t; | ||
| void cleanup(void* data) { | ||
| ((EnvWrap*) data)->closeEnv(); | ||
| EnvWrap* envWrap = (EnvWrap*) data; | ||
| envWrap->cleanupHookRegistered = false; | ||
| envWrap->closeEnv(); | ||
| } | ||
@@ -329,3 +334,6 @@ | ||
| return throwLmdbError(info.Env(), rc); | ||
| napi_add_env_cleanup_hook(napiEnv, cleanup, this); | ||
| if (!cleanupHookRegistered) { | ||
| napi_add_env_cleanup_hook(napiEnv, cleanup, this); | ||
| cleanupHookRegistered = true; | ||
| } | ||
| return info.Env().Undefined(); | ||
@@ -410,3 +418,5 @@ } | ||
| openEnvWraps = new std::vector<EnvWrap*>; | ||
| napi_add_env_cleanup_hook(napiEnv, cleanupEnvWraps, nullptr); | ||
| // Register this exact vector pointer so repeated hook registrations use | ||
| // distinct (fun, arg) pairs per allocation. | ||
| napi_add_env_cleanup_hook(napiEnv, cleanupEnvWraps, openEnvWraps); | ||
| } | ||
@@ -735,3 +745,6 @@ openEnvWraps->push_back(this); | ||
| } | ||
| napi_remove_env_cleanup_hook(napiEnv, cleanup, this); | ||
| if (cleanupHookRegistered) { | ||
| cleanupHookRegistered = false; | ||
| napi_remove_env_cleanup_hook(napiEnv, cleanup, this); | ||
| } | ||
| cleanupStrayTxns(); | ||
@@ -1392,2 +1405,1 @@ if (!hasLock) | ||
| // THE SOFTWARE. | ||
+3
-0
@@ -318,2 +318,4 @@ #ifndef NODE_LMDB_H | ||
| napi_env napiEnv; | ||
| // Track whether this EnvWrap currently owns a registered env cleanup hook. | ||
| bool cleanupHookRegistered; | ||
| // compression settings and space | ||
@@ -329,2 +331,3 @@ Compression *compression; | ||
| friend class TxnWrap; | ||
| friend void cleanup(void* data); | ||
| friend class DbiWrap; | ||
@@ -331,0 +334,0 @@ |
Sorry, the diff of this file is too big to display
2543192
0.02%