mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 18:24:20 +01:00
only close connection in case of reference count is 1
Due to how `execute` is implemented, it returns a `Connection` clone which internally shares a turso_core::Connection with every other Connection. Since `execute` returns `Connection` and immediatly it is dropped, it will close connection, checkpoint and leave database in weird state.
This commit is contained in:
@@ -296,9 +296,11 @@ impl Connection {
|
||||
|
||||
impl Drop for Connection {
|
||||
fn drop(&mut self) {
|
||||
self.conn
|
||||
.close()
|
||||
.expect("Failed to drop (close) connection");
|
||||
if Arc::strong_count(&self.conn) == 1 {
|
||||
self.conn
|
||||
.close()
|
||||
.expect("Failed to drop (close) connection");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user