diff --git a/src/transactions.rs b/src/transactions.rs index 9e22f5f2..871bd6b8 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -1213,7 +1213,7 @@ impl ReadTransaction { definition.name().to_string(), header.get_root(), PageHint::Clean, - self.tree.clone_transaction_guard(), + self.tree.transaction_guard().clone(), self.mem.clone(), )?) } @@ -1250,7 +1250,7 @@ impl ReadTransaction { header.get_root(), header.get_length(), PageHint::Clean, - self.tree.clone_transaction_guard(), + self.tree.transaction_guard().clone(), self.mem.clone(), )?) } @@ -1296,9 +1296,7 @@ impl ReadTransaction { /// /// Returns `ReadTransactionStillInUse` error if a table or other object retrieved from the transaction still references this transaction pub fn close(self) -> Result<(), TransactionError> { - let cloned = self.tree.clone_transaction_guard(); - // Check for count greater than 2 because we just cloned the guard to get a reference to it - if Arc::strong_count(&cloned) > 2 { + if Arc::strong_count(self.tree.transaction_guard()) > 1 { return Err(TransactionError::ReadTransactionStillInUse(self)); } // No-op, just drop ourself diff --git a/src/tree_store/btree.rs b/src/tree_store/btree.rs index bedcd631..23229956 100644 --- a/src/tree_store/btree.rs +++ b/src/tree_store/btree.rs @@ -575,8 +575,8 @@ impl Btree { }) } - pub(crate) fn clone_transaction_guard(&self) -> Arc { - self.transaction_guard.clone() + pub(crate) fn transaction_guard(&self) -> &Arc { + &self.transaction_guard } pub(crate) fn get_root(&self) -> Option { diff --git a/src/tree_store/table_tree.rs b/src/tree_store/table_tree.rs index 909bba8d..b9e2051f 100644 --- a/src/tree_store/table_tree.rs +++ b/src/tree_store/table_tree.rs @@ -439,8 +439,8 @@ impl TableTree { }) } - pub(crate) fn clone_transaction_guard(&self) -> Arc { - self.tree.clone_transaction_guard() + pub(crate) fn transaction_guard(&self) -> &Arc { + self.tree.transaction_guard() } // root_page: the root of the master table