Skip to content

Commit b44611f

Browse files
committed
Timer service cleans up properly
1 parent 5d16efd commit b44611f

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎src/corosio/src/detail/posix/resolver_service.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class posix_resolver_impl
389389

390390
void release() override;
391391

392-
std::coroutine_handle<> resolve(
392+
void resolve(
393393
std::coroutine_handle<>,
394394
capy::executor_ref,
395395
std::string_view host,
@@ -399,7 +399,7 @@ class posix_resolver_impl
399399
std::error_code*,
400400
resolver_results*) override;
401401

402-
std::coroutine_handle<> reverse_resolve(
402+
void reverse_resolve(
403403
std::coroutine_handle<>,
404404
capy::executor_ref,
405405
endpoint const& ep,

‎src/corosio/src/detail/posix/signals.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class posix_signal_impl
189189

190190
void release() override;
191191

192-
std::coroutine_handle<> wait(
192+
void wait(
193193
std::coroutine_handle<>,
194194
capy::executor_ref,
195195
std::stop_token,

‎src/corosio/src/detail/timer_service.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,20 @@ class timer_service_impl : public timer_service
107107

108108
void shutdown() override
109109
{
110+
// Cancel all waiting timers and destroy coroutine handles
111+
// This properly decrements outstanding_work_ for each waiting timer
110112
while (auto* impl = timers_.pop_front())
113+
{
114+
if (impl->waiting_)
115+
{
116+
impl->waiting_ = false;
117+
// Destroy the coroutine handle without resuming
118+
impl->h_.destroy();
119+
// Decrement work count to avoid leak
120+
sched_->on_work_finished();
121+
}
111122
delete impl;
123+
}
112124
while (auto* impl = free_list_.pop_front())
113125
delete impl;
114126
}

0 commit comments

Comments
 (0)