timer: fix uv_timer_start on closing timer
Return `UV_EINVAL` in this case. Fixes: https://github.com/libuv/libuv/issues/2416 PR-URL: https://github.com/libuv/libuv/pull/2424 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
fa41f13444
commit
2ee2d4622a
@ -74,7 +74,7 @@ int uv_timer_start(uv_timer_t* handle,
|
||||
uint64_t repeat) {
|
||||
uint64_t clamped_timeout;
|
||||
|
||||
if (cb == NULL)
|
||||
if (uv__is_closing(handle) || cb == NULL)
|
||||
return UV_EINVAL;
|
||||
|
||||
if (uv__is_active(handle))
|
||||
|
||||
@ -197,6 +197,7 @@ TEST_DECLARE (timer_huge_timeout)
|
||||
TEST_DECLARE (timer_huge_repeat)
|
||||
TEST_DECLARE (timer_run_once)
|
||||
TEST_DECLARE (timer_from_check)
|
||||
TEST_DECLARE (timer_is_closing)
|
||||
TEST_DECLARE (timer_null_callback)
|
||||
TEST_DECLARE (timer_early_check)
|
||||
TEST_DECLARE (idle_starvation)
|
||||
@ -729,6 +730,7 @@ TASK_LIST_START
|
||||
TEST_ENTRY (timer_huge_repeat)
|
||||
TEST_ENTRY (timer_run_once)
|
||||
TEST_ENTRY (timer_from_check)
|
||||
TEST_ENTRY (timer_is_closing)
|
||||
TEST_ENTRY (timer_null_callback)
|
||||
TEST_ENTRY (timer_early_check)
|
||||
|
||||
|
||||
@ -292,6 +292,19 @@ TEST_IMPL(timer_run_once) {
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(timer_is_closing) {
|
||||
uv_timer_t handle;
|
||||
|
||||
ASSERT(0 == uv_timer_init(uv_default_loop(), &handle));
|
||||
uv_close((uv_handle_t *)&handle, NULL);
|
||||
|
||||
ASSERT(UV_EINVAL == uv_timer_start(&handle, never_cb, 100, 100));
|
||||
|
||||
MAKE_VALGRIND_HAPPY();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TEST_IMPL(timer_null_callback) {
|
||||
uv_timer_t handle;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user