@nxtedition/rocksdb 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.cc CHANGED
@@ -54,8 +54,6 @@ struct Database final {
54
54
  ~Database() { assert(!db); }
55
55
 
56
56
  rocksdb::Status Close() {
57
- std::lock_guard<std::mutex> lock(mutex);
58
-
59
57
  if (!db) {
60
58
  return rocksdb::Status::OK();
61
59
  }
@@ -91,8 +89,8 @@ struct Database final {
91
89
  }
92
90
  }
93
91
 
94
- int refs = 0;
95
92
  std::mutex mutex;
93
+ int refs = 0;
96
94
  std::string location;
97
95
  std::unique_ptr<rocksdb::DB> db;
98
96
  std::set<Closable*> closables;
@@ -470,11 +468,7 @@ struct Iterator final : public BaseIterator {
470
468
 
471
469
  static void FinalizeDatabase(napi_env env, void* data, void* hint) {
472
470
  if (data) {
473
- auto database = reinterpret_cast<Database*>(data);
474
-
475
- std::lock_guard<std::mutex> lock(database->mutex);
476
-
477
- database->Unref();
471
+ reinterpret_cast<Database*>(data)->Unref();
478
472
  }
479
473
  }
480
474
 
@@ -507,10 +501,7 @@ NAPI_METHOD(db_init) {
507
501
  napi_value result;
508
502
  NAPI_STATUS_THROWS(napi_create_external(env, database, FinalizeDatabase, nullptr, &result));
509
503
 
510
- {
511
- std::lock_guard<std::mutex> lock(database->mutex);
512
- database->Ref();
513
- }
504
+ database->Ref();
514
505
 
515
506
  return result;
516
507
  }
@@ -776,8 +767,6 @@ NAPI_METHOD(db_open) {
776
767
  Database* database;
777
768
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
778
769
 
779
- std::lock_guard<std::mutex> lock(database->mutex);
780
-
781
770
  if (database->db) {
782
771
  napi_value columns;
783
772
  NAPI_STATUS_THROWS(napi_create_object(env, &columns));
@@ -893,16 +882,11 @@ NAPI_METHOD(db_open) {
893
882
 
894
883
  rocksdb::DB* db = nullptr;
895
884
 
896
- // TODO (fix): There is a race condition here... Check if we are already opening the database.
897
-
898
885
  const auto status = descriptors.empty()
899
886
  ? rocksdb::DB::Open(dbOptions, database->location, &db)
900
887
  : rocksdb::DB::Open(dbOptions, database->location, descriptors, &handles, &db);
901
888
 
902
- {
903
- std::lock_guard<std::mutex> lock(database->mutex);
904
- database->db.reset(db);
905
- }
889
+ database->db.reset(db);
906
890
 
907
891
  return status;
908
892
  },
@@ -943,8 +927,6 @@ NAPI_METHOD(db_close) {
943
927
  Database* database;
944
928
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
945
929
 
946
- std::lock_guard<std::mutex> lock(database->mutex);
947
-
948
930
  auto callback = argv[1];
949
931
 
950
932
  struct State {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",