Skip to content

Commit

Permalink
fix memleak in connect_to_ceph fail (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ten0 authored Oct 19, 2024
1 parent d049e23 commit ed61660
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ceph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ pub fn connect_to_ceph(user_id: &str, config_file: &str) -> RadosResult<Rados> {
if ret_code < 0 {
return Err(ret_code.into());
}
// Instantiate Rados struct to call shutdown on drop.
// Doc specifies that it's not necessary to call rados_shutdown if
// rados_connect hasn't run, but that seems incorrect.
let rados = Rados {
rados: cluster_handle,
phantom: PhantomData,
};
let ret_code = rados_conf_read_file(cluster_handle, conf_file.as_ptr());
if ret_code < 0 {
return Err(ret_code.into());
Expand All @@ -403,10 +410,7 @@ pub fn connect_to_ceph(user_id: &str, config_file: &str) -> RadosResult<Rados> {
if ret_code < 0 {
return Err(ret_code.into());
}
Ok(Rados {
rados: cluster_handle,
phantom: PhantomData,
})
Ok(rados)
}
}

Expand Down

0 comments on commit ed61660

Please sign in to comment.