Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/host/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,21 +1018,22 @@ namespace ccf

process_launcher.stop();

// Continue running the loop long enough for the on_close
// callbacks to be despatched, so as to avoid memory being
// leaked by handles. Capped out of abundance of caution.
constexpr size_t max_iterations = 1000;
size_t close_iterations = max_iterations;
while ((uv_loop_alive(uv_default_loop()) != 0) && (close_iterations > 0))
constexpr size_t max_close_iterations = 1000;
int close_iterations = max_close_iterations;
int loop_close_rc = 0;
while (close_iterations-- > 0)
Comment thread
achamayou marked this conversation as resolved.
Outdated
Comment thread
cjen1-msft marked this conversation as resolved.
Outdated
{
loop_close_rc = uv_loop_close(uv_default_loop());
if (loop_close_rc != UV_EBUSY)
{
break;
}
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
close_iterations--;
std::this_thread::sleep_for(10ms);
Comment thread
cjen1-msft marked this conversation as resolved.
}
LOG_INFO_FMT(
"Ran an extra {} cleanup iteration(s)",
max_iterations - close_iterations);

auto loop_close_rc = uv_loop_close(uv_default_loop());
max_close_iterations - close_iterations);
if (loop_close_rc != 0)
{
LOG_FAIL_FMT(
Expand Down