From 77cb29a723b1bda2cd4f938031d352e46bd25fed Mon Sep 17 00:00:00 2001 From: Brian Mazza Date: Mon, 4 Mar 2013 22:17:50 -0600 Subject: [PATCH] unix: make uv_timer_init() initialize repeat uv_timer_get_repeat() should return 0 for timers that haven't been started. --- src/unix/timer.c | 1 + test/test-list.h | 2 ++ test/test-timer.c | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/src/unix/timer.c b/src/unix/timer.c index 41038c8a..ab1f1cee 100644 --- a/src/unix/timer.c +++ b/src/unix/timer.c @@ -45,6 +45,7 @@ RB_GENERATE_STATIC(uv__timers, uv_timer_s, tree_entry, uv__timer_cmp) int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); handle->timer_cb = NULL; + handle->repeat = 0; return 0; } diff --git a/test/test-list.h b/test/test-list.h index 2341463a..53212aa2 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -95,6 +95,7 @@ TEST_DECLARE (shutdown_eof) TEST_DECLARE (callback_stack) TEST_DECLARE (error_message) TEST_DECLARE (timer) +TEST_DECLARE (timer_init) TEST_DECLARE (timer_again) TEST_DECLARE (timer_start_twice) TEST_DECLARE (timer_order) @@ -336,6 +337,7 @@ TASK_LIST_START TEST_ENTRY (error_message) TEST_ENTRY (timer) + TEST_ENTRY (timer_init) TEST_ENTRY (timer_again) TEST_ENTRY (timer_start_twice) TEST_ENTRY (timer_order) diff --git a/test/test-timer.c b/test/test-timer.c index 60b080d2..f15a3571 100644 --- a/test/test-timer.c +++ b/test/test-timer.c @@ -156,6 +156,18 @@ TEST_IMPL(timer_start_twice) { } +TEST_IMPL(timer_init) { + uv_timer_t handle; + + ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); + ASSERT(0 == uv_timer_get_repeat(&handle)); + ASSERT(!uv_is_active((uv_handle_t*)&handle)); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + static void order_cb_a(uv_timer_t *handle, int status) { ASSERT(order_cb_called++ == *(int*)handle->data); }