Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: make uv_timer_init() initialize repeat
Browse files Browse the repository at this point in the history
uv_timer_get_repeat() should return 0 for timers that haven't been
started.
  • Loading branch information
Brian Mazza authored and bnoordhuis committed Mar 19, 2013
1 parent a9740c9 commit 77cb29a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/unix/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions test/test-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions test/test-timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 77cb29a

Please sign in to comment.