Make sure all resources are cleaned up properly in xconnect

This commit is contained in:
PThorpe92 2025-05-24 16:38:33 -04:00
parent a4ed464ec4
commit d63f9d8cff
No known key found for this signature in database
GPG key ID: 66DB3FBACBDD05CC
3 changed files with 52 additions and 33 deletions

View file

@ -779,10 +779,15 @@ pub struct VirtualTable {
impl Drop for VirtualTable {
fn drop(&mut self) {
if let Some(conn) = self.connection_ptr.borrow_mut().take() {
// free the memory for the limbo_ext::Conn
if conn.is_null() {
return;
}
// free the memory for the limbo_ext::Conn itself
let conn = unsafe { Box::from_raw(conn) };
// frees the boxed Weak pointer
conn.close();
}
*self.connection_ptr.borrow_mut() = None;
}
}