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

Commit

Permalink
Merge branch 'v0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Apr 18, 2013
2 parents 2d89b4b + a396388 commit 79f9629
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/unix/internal.h
Expand Up @@ -47,7 +47,7 @@
#endif

#define STATIC_ASSERT(expr) \
void uv__static_assert(int static_assert_failed[0 - !(expr)])
void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])

#define ACCESS_ONCE(type, var) \
(*(volatile type*) &(var))
Expand Down
5 changes: 1 addition & 4 deletions src/win/core.c
Expand Up @@ -205,9 +205,7 @@ static void uv_poll(uv_loop_t* loop, int block) {
if (overlapped) {
/* Package was dequeued */
req = uv_overlapped_to_req(overlapped);

uv_insert_pending_req(loop, req);

} else if (GetLastError() != WAIT_TIMEOUT) {
/* Serious error */
uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus");
Expand All @@ -229,14 +227,13 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
timeout = 0;
}

assert(pGetQueuedCompletionStatusEx);

success = pGetQueuedCompletionStatusEx(loop->iocp,
overlappeds,
ARRAY_SIZE(overlappeds),
&count,
timeout,
FALSE);

if (success) {
for (i = 0; i < count; i++) {
/* Package was dequeued */
Expand Down
17 changes: 14 additions & 3 deletions src/win/timer.c
Expand Up @@ -87,6 +87,17 @@ void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) {
}


static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) {
uint64_t clamped_timeout;

clamped_timeout = loop_time + timeout;
if (clamped_timeout < timeout)
clamped_timeout = (uint64_t) -1;

return clamped_timeout;
}


int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout,
uint64_t repeat) {
uv_loop_t* loop = handle->loop;
Expand All @@ -97,7 +108,7 @@ int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout,
}

handle->timer_cb = timer_cb;
handle->due = loop->time + timeout;
handle->due = get_clamped_due_time(loop->time, timeout);
handle->repeat = repeat;
handle->flags |= UV_HANDLE_ACTIVE;
uv__handle_start(handle);
Expand Down Expand Up @@ -143,7 +154,7 @@ int uv_timer_again(uv_timer_t* handle) {
}

if (handle->repeat) {
handle->due = loop->time + handle->repeat;
handle->due = get_clamped_due_time(loop->time, handle->repeat);

if (RB_INSERT(uv_timer_tree_s, &loop->timers, handle) != NULL) {
uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT");
Expand Down Expand Up @@ -212,7 +223,7 @@ void uv_process_timers(uv_loop_t* loop) {

if (timer->repeat != 0) {
/* If it is a repeating timer, reschedule with repeat timeout. */
timer->due += timer->repeat;
timer->due = get_clamped_due_time(timer->due, timer->repeat);
if (timer->due < loop->time) {
timer->due = loop->time;
}
Expand Down

0 comments on commit 79f9629

Please sign in to comment.