Skip to content
Snippets Groups Projects
Commit 07d92026 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

Merge branch 'uv_timer_t-corruption' into 'master'

daemon/session: fix an issue with timers

See merge request !1195
parents 3da9005a 91ce241a
Branches
Tags
1 merge request!1195daemon/session: fix an issue with timers
Pipeline #86127 failed with stages
in 34 minutes and 58 seconds
......@@ -10,6 +10,7 @@ Bugfixes
- trust_anchors.set_insecure: improve precision (#673, !1177)
- plug memory leaks related to TCP (!1182)
- policy.FLAGS: fix not applying properly in edge cases (!1179)
- fix a crash with older libuv inside timer processing (!1195)
Incompatible changes
--------------------
......
......@@ -503,18 +503,24 @@ int session_timer_start(struct session *session, uv_timer_cb cb,
uint64_t timeout, uint64_t repeat)
{
uv_timer_t *timer = &session->timeout;
// Session might be closing and get here e.g. through a late on_send callback.
const bool is_closing = uv_is_closing((uv_handle_t *)timer);
if (is_closing || kr_fails_assert(is_closing == session->sflags.closing))
return kr_error(EINVAL);
if (kr_fails_assert(timer->data == session))
return kr_error(EINVAL);
int ret = uv_timer_start(timer, cb, timeout, repeat);
if (ret != 0) {
uv_timer_stop(timer);
return kr_error(ENOMEM);
return kr_error(ret);
}
return 0;
return kr_ok();
}
int session_timer_restart(struct session *session)
{
kr_require(!uv_is_closing((uv_handle_t *)&session->timeout));
return uv_timer_again(&session->timeout);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment