Skip to content

Commit

Permalink
CCDB: Ensure CCDBDownloader's libuv loop is properly deleted (AliceO2…
Browse files Browse the repository at this point in the history
…Group#13238)

My valgrind checks were showing that the internal CCDBDownloader's libuv loop resources were not fully released. With this fix, valgrind is happy.

The change is based on the following premises:
- `uv_loop_alive` returns true if there are *active* handles
- `uv_loop_close` returns `UV_EBUSY` if there are *open* handles.
- we need to succesfully call `uv_loop_close` to clear `mUVLoop` resources

Thus, in case that we would not have *active* handles, we would never close *open* ones, and consequently would not manage to call `uv_loop_close` without getting `UV_EBUSY`.
  • Loading branch information
knopers8 authored Jun 21, 2024
1 parent 4d2f4aa commit 1ff1138
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CCDB/src/CCDBDownloader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CCDBDownloader::~CCDBDownloader()

if (!mExternalLoop) {
// Schedule all handles to close. Execute loop to allow them to execute their destructors.
while (uv_loop_alive(mUVLoop) && uv_loop_close(mUVLoop) == UV_EBUSY) {
while (uv_loop_alive(mUVLoop) || (uv_loop_close(mUVLoop) == UV_EBUSY)) {
uv_walk(mUVLoop, closeHandles, this);
uv_run(mUVLoop, UV_RUN_ONCE);
}
Expand Down

0 comments on commit 1ff1138

Please sign in to comment.