Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
deps: upgrade libuv to 2ec0986
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed May 27, 2012
1 parent 1f3e4a7 commit 0fd2834
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
11 changes: 6 additions & 5 deletions deps/uv/src/unix/timer.c
Expand Up @@ -52,11 +52,12 @@ int uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) {
}


int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, int64_t timeout,
int64_t repeat) {
if (uv__is_active(timer)) {
return -1;
}
int uv_timer_start(uv_timer_t* timer,
uv_timer_cb cb,
int64_t timeout,
int64_t repeat) {
if (uv__is_active(timer))
uv_timer_stop(timer);

timer->timer_cb = cb;

Expand Down
6 changes: 2 additions & 4 deletions deps/uv/src/uv-common.h
Expand Up @@ -155,16 +155,14 @@ UNUSED static int uv__is_active(const uv_handle_t* h) {

UNUSED static void uv__handle_start(uv_handle_t* h) {
if (h->flags & UV__ACTIVE) return;
if (!(h->flags & UV__REF)) return;
if (h->flags & UV__REF) uv__active_handle_add(h);
h->flags |= UV__ACTIVE;
uv__active_handle_add(h);
}
#define uv__handle_start(h) uv__handle_start((uv_handle_t*)(h))

UNUSED static void uv__handle_stop(uv_handle_t* h) {
if (!(h->flags & UV__ACTIVE)) return;
if (!(h->flags & UV__REF)) return;
uv__active_handle_rm(h);
if (h->flags & UV__REF) uv__active_handle_rm(h);
h->flags &= ~UV__ACTIVE;
}
#define uv__handle_stop(h) uv__handle_stop((uv_handle_t*)(h))
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/test/runner.c
Expand Up @@ -19,6 +19,7 @@
* IN THE SOFTWARE.
*/

#include <stdio.h>
#include <string.h>

#include "runner.h"
Expand Down Expand Up @@ -92,6 +93,11 @@ int run_test(const char* test, int timeout, int benchmark_output) {
main_proc = NULL;
process_count = 0;

#ifndef _WIN32
/* Clean up stale socket from previous run. */
remove(TEST_PIPENAME);
#endif

/* If it's a helper the user asks for, start it directly. */
for (task = TASKS; task->main; task++) {
if (task->is_helper && strcmp(test, task->process_name) == 0) {
Expand Down
5 changes: 0 additions & 5 deletions deps/uv/test/test-ipc-send-recv.c
Expand Up @@ -120,11 +120,6 @@ TEST_IMPL(ipc_send_recv_pipe) {
r = uv_pipe_init(uv_default_loop(), &ctx.send.pipe, 1);
ASSERT(r == 0);

#ifndef _WIN32
/* Clean up stale socket from previous test run. */
remove(TEST_PIPENAME);
#endif

r = uv_pipe_bind(&ctx.send.pipe, TEST_PIPENAME);
ASSERT(r == 0);

Expand Down
2 changes: 2 additions & 0 deletions deps/uv/test/test-list.h
Expand Up @@ -77,6 +77,7 @@ TEST_DECLARE (callback_stack)
TEST_DECLARE (error_message)
TEST_DECLARE (timer)
TEST_DECLARE (timer_again)
TEST_DECLARE (timer_start_twice)
TEST_DECLARE (idle_starvation)
TEST_DECLARE (loop_handles)
TEST_DECLARE (get_loadavg)
Expand Down Expand Up @@ -266,6 +267,7 @@ TASK_LIST_START

TEST_ENTRY (timer)
TEST_ENTRY (timer_again)
TEST_ENTRY (timer_start_twice)

TEST_ENTRY (idle_starvation)

Expand Down
4 changes: 0 additions & 4 deletions deps/uv/test/test-pipe-bind-error.c
Expand Up @@ -27,10 +27,8 @@

#ifdef _WIN32
# define BAD_PIPENAME "bad-pipe"
# define UNLINK_PIPE(name)
#else
# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there"
# define UNLINK_PIPE(name) remove(name)
#endif


Expand All @@ -47,8 +45,6 @@ TEST_IMPL(pipe_bind_error_addrinuse) {
uv_pipe_t server1, server2;
int r;

UNLINK_PIPE(TEST_PIPENAME);

r = uv_pipe_init(uv_default_loop(), &server1, 0);
ASSERT(r == 0);
r = uv_pipe_bind(&server1, TEST_PIPENAME);
Expand Down
22 changes: 22 additions & 0 deletions deps/uv/test/test-timer.c
Expand Up @@ -35,6 +35,7 @@ static void once_close_cb(uv_handle_t* handle) {
printf("ONCE_CLOSE_CB\n");

ASSERT(handle != NULL);
ASSERT(!uv_is_active(handle));

once_close_cb_called++;
}
Expand All @@ -45,6 +46,7 @@ static void once_cb(uv_timer_t* handle, int status) {

ASSERT(handle != NULL);
ASSERT(status == 0);
ASSERT(!uv_is_active((uv_handle_t*)handle));

once_cb_called++;

Expand All @@ -69,6 +71,7 @@ static void repeat_cb(uv_timer_t* handle, int status) {

ASSERT(handle != NULL);
ASSERT(status == 0);
ASSERT(uv_is_active((uv_handle_t*)handle));

repeat_cb_called++;

Expand Down Expand Up @@ -128,3 +131,22 @@ TEST_IMPL(timer) {

return 0;
}


TEST_IMPL(timer_start_twice) {
uv_timer_t once;
int r;

r = uv_timer_init(uv_default_loop(), &once);
ASSERT(r == 0);
r = uv_timer_start(&once, never_cb, 86400 * 1000, 0);
ASSERT(r == 0);
r = uv_timer_start(&once, once_cb, 10, 0);
ASSERT(r == 0);
r = uv_run(uv_default_loop());
ASSERT(r == 0);

ASSERT(once_cb_called == 1);

return 0;
}

0 comments on commit 0fd2834

Please sign in to comment.