aboutsummaryrefslogtreecommitdiff
path: root/deps/uv/src
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-03-21 14:59:16 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-03-21 14:59:16 +0100
commite47a3e3ff4436b5d58ec95bb7588f3f185cc4fa8 (patch)
tree78610bfd6c2b8104b93283df6145190cac65f3c0 /deps/uv/src
parent3dd7938c03389371ce1d142a8558a98b450ca2ee (diff)
downloadandroid-node-v8-e47a3e3ff4436b5d58ec95bb7588f3f185cc4fa8.tar.gz
android-node-v8-e47a3e3ff4436b5d58ec95bb7588f3f185cc4fa8.tar.bz2
android-node-v8-e47a3e3ff4436b5d58ec95bb7588f3f185cc4fa8.zip
deps: upgrade libuv to 9b61939
Diffstat (limited to 'deps/uv/src')
-rw-r--r--deps/uv/src/unix/timer.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/deps/uv/src/unix/timer.c b/deps/uv/src/unix/timer.c
index 41038c8ac0..57d32f581c 100644
--- a/deps/uv/src/unix/timer.c
+++ b/deps/uv/src/unix/timer.c
@@ -21,6 +21,8 @@
#include "uv.h"
#include "internal.h"
#include <assert.h>
+#include <limits.h>
+
static int uv__timer_cmp(const uv_timer_t* a, const uv_timer_t* b) {
if (a->timeout < b->timeout)
@@ -45,6 +47,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;
}
@@ -54,11 +57,17 @@ int uv_timer_start(uv_timer_t* handle,
uv_timer_cb cb,
uint64_t timeout,
uint64_t repeat) {
+ uint64_t clamped_timeout;
+
if (uv__is_active(handle))
uv_timer_stop(handle);
+ clamped_timeout = handle->loop->time + timeout;
+ if (clamped_timeout < timeout)
+ clamped_timeout = (uint64_t) -1;
+
handle->timer_cb = cb;
- handle->timeout = handle->loop->time + timeout;
+ handle->timeout = clamped_timeout;
handle->repeat = repeat;
/* start_id is the second index to be compared in uv__timer_cmp() */
handle->start_id = handle->loop->timer_counter++;
@@ -106,6 +115,7 @@ uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
int uv__next_timeout(const uv_loop_t* loop) {
const uv_timer_t* handle;
+ uint64_t diff;
/* RB_MIN expects a non-const tree root. That's okay, it doesn't modify it. */
handle = RB_MIN(uv__timers, (struct uv__timers*) &loop->timer_handles);
@@ -116,7 +126,11 @@ int uv__next_timeout(const uv_loop_t* loop) {
if (handle->timeout <= loop->time)
return 0;
- return handle->timeout - loop->time;
+ diff = handle->timeout - loop->time;
+ if (diff > INT_MAX)
+ diff = INT_MAX;
+
+ return diff;
}