Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'origin/v0.6'

Conflicts:
	src/win/util.c
  • Loading branch information...
commit 71f6c0edb85b8de59fd8b2e6f2822ee430bc6d5b 2 parents e7758e1 + 0e6e4ab
@bnoordhuis bnoordhuis authored
View
2  include/uv-private/ev.h
@@ -562,6 +562,8 @@ EV_MAYBE_UNUSED ev_is_default_loop (EV_P)
/* create and destroy alternative loops that don't handle signals */
struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0));
+int ev_loop_refcount (EV_P);
+
ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
#else
View
3  include/uv.h
@@ -202,6 +202,9 @@ typedef struct uv_work_s uv_work_t;
UV_EXTERN uv_loop_t* uv_loop_new(void);
UV_EXTERN void uv_loop_delete(uv_loop_t*);
+/* This is a debugging tool. It's NOT part of the official API. */
+UV_EXTERN int uv_loop_refcount(const uv_loop_t*);
+
/*
* Returns the default loop.
View
11 src/unix/core.c
@@ -63,12 +63,6 @@ void uv__next(EV_P_ ev_idle* watcher, int revents);
static void uv__finish_close(uv_handle_t* handle);
-
-#ifndef __GNUC__
-#define __attribute__(a)
-#endif
-
-
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
uv_udp_t* udp;
uv_async_t* async;
@@ -202,6 +196,11 @@ void uv_loop_delete(uv_loop_t* loop) {
}
+int uv_loop_refcount(const uv_loop_t* loop) {
+ return ev_loop_refcount(loop->ev);
+}
+
+
uv_loop_t* uv_default_loop(void) {
if (default_loop_ptr)
return default_loop_ptr;
View
6 src/unix/ev/ev.c
@@ -1958,6 +1958,12 @@ ev_loop_new (unsigned int flags)
#endif /* multiplicity */
+int
+ev_loop_refcount (EV_P)
+{
+ return activecnt;
+}
+
#if EV_VERIFY
static void noinline
verify_watcher (EV_P_ W w)
View
12 src/unix/udp.c
@@ -42,6 +42,10 @@ static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) {
int flags;
+ if (ev_is_active(w)) {
+ return;
+ }
+
assert(w == &handle->read_watcher
|| w == &handle->write_watcher);
@@ -51,17 +55,23 @@ static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) {
ev_set_cb(w, uv__udp_io);
ev_io_set(w, handle->fd, flags);
ev_io_start(handle->loop->ev, w);
+ ev_unref(handle->loop->ev);
}
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w) {
int flags;
+ if (!ev_is_active(w)) {
+ return;
+ }
+
assert(w == &handle->read_watcher
|| w == &handle->write_watcher);
flags = (w == &handle->read_watcher ? EV_READ : EV_WRITE);
+ ev_ref(handle->loop->ev);
ev_io_stop(handle->loop->ev, w);
ev_io_set(w, -1, flags);
ev_set_cb(w, NULL);
@@ -332,7 +342,7 @@ static int uv__bind(uv_udp_t* handle,
goto out;
}
#else
- uv__set_sys_error((uv_handle_t*)handle, ENOTSUP);
+ uv__set_sys_error(handle->loop, ENOTSUP);
goto out;
#endif
}
View
5 src/win/core.c
@@ -116,6 +116,11 @@ void uv_loop_delete(uv_loop_t* loop) {
}
+int uv_loop_refcount(const uv_loop_t* loop) {
+ return loop->refs;
+}
+
+
void uv_ref(uv_loop_t* loop) {
loop->refs++;
}
View
74 src/win/fs.c
@@ -490,38 +490,69 @@ void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
void fs__stat(uv_fs_t* req, const wchar_t* path) {
+ HANDLE file;
+ WIN32_FIND_DATAW ent;
int result;
- unsigned short mode;
- fs__open(req, path, _O_RDONLY, 0);
- if (req->result == -1) {
+ req->ptr = NULL;
+
+ file = FindFirstFileExW(path, FindExInfoStandard, &ent,
+ FindExSearchNameMatch, NULL, 0);
+
+ if (file == INVALID_HANDLE_VALUE) {
+ SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
return;
}
- result = _fstati64(req->result, &req->stat);
- if (result == -1) {
- req->ptr = NULL;
- } else {
+ FindClose(file);
- /*
- * VC CRT doesn't properly set S_IFDIR in _fstati64,
- * so we set it here if path is a directory.
- */
- if (GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY) {
- mode = req->stat.st_mode;
- mode &= ~_S_IFMT;
- mode |= _S_IFDIR;
-
- req->stat.st_mode = mode;
- assert((req->stat.st_mode & _S_IFMT) == _S_IFDIR);
+ if (ent.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
+ ent.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
+ fs__open(req, path, _O_RDONLY, 0);
+ if (req->result != -1) {
+ result = _fstati64(req->result, &req->stat);
+ _close(req->result);
+
+ if (result != -1) {
+ req->ptr = &req->stat;
+ }
+
+ SET_REQ_RESULT(req, result);
}
- req->ptr = &req->stat;
+ return;
}
- _close(req->result);
+ req->stat.st_ino = 0;
+ req->stat.st_uid = 0;
+ req->stat.st_gid = 0;
+ req->stat.st_mode = 0;
+ req->stat.st_rdev = 0;
+ req->stat.st_dev = 0;
+ req->stat.st_nlink = 1;
- SET_REQ_RESULT(req, result);
+ if (ent.dwFileAttributes & FILE_ATTRIBUTE_READONLY ) {
+ req->stat.st_mode |= (_S_IREAD + (_S_IREAD >> 3) + (_S_IREAD >> 6));
+ } else {
+ req->stat.st_mode |= ((_S_IREAD|_S_IWRITE) + ((_S_IREAD|_S_IWRITE) >> 3) +
+ ((_S_IREAD|_S_IWRITE) >> 6));
+ }
+
+ if (ent.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ req->stat.st_mode |= _S_IFDIR;
+ } else {
+ req->stat.st_mode |= _S_IFREG;
+ }
+
+ uv_filetime_to_time_t(&ent.ftLastWriteTime, &(req->stat.st_mtime));
+ uv_filetime_to_time_t(&ent.ftLastAccessTime, &(req->stat.st_atime));
+ uv_filetime_to_time_t(&ent.ftCreationTime, &(req->stat.st_ctime));
+
+ req->stat.st_size = ((int64_t)ent.nFileSizeHigh << 32) +
+ (int64_t)ent.nFileSizeLow;
+
+ req->ptr = &req->stat;
+ req->result = 0;
}
@@ -1543,3 +1574,4 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
req->flags |= UV_FS_CLEANEDUP;
}
+
View
4 src/win/internal.h
@@ -284,10 +284,8 @@ void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle);
/* Utils */
int uv_parent_pid();
-
-
+void uv_filetime_to_time_t(FILETIME* file_time, time_t* stat_time);
void uv_fatal_error(const int errorno, const char* syscall);
-
uv_err_code uv_translate_sys_error(int sys_errno);
#define SET_REQ_STATUS(req, status) \
View
23 src/win/util.c
@@ -24,6 +24,7 @@
#include <malloc.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "uv.h"
#include "internal.h"
@@ -579,3 +580,25 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses,
free(addresses);
}
+
+
+void uv_filetime_to_time_t(FILETIME* file_time, time_t* stat_time) {
+ FILETIME local_time;
+ SYSTEMTIME system_time;
+ struct tm time;
+
+ if ((file_time->dwLowDateTime || file_time->dwHighDateTime) &&
+ FileTimeToLocalFileTime(file_time, &local_time) &&
+ FileTimeToSystemTime(&local_time, &system_time)) {
+ time.tm_year = system_time.wYear - 1900;
+ time.tm_mon = system_time.wMonth - 1;
+ time.tm_mday = system_time.wDay;
+ time.tm_hour = system_time.wHour;
+ time.tm_min = system_time.wMinute;
+ time.tm_sec = system_time.wSecond;
+
+ *stat_time = mktime(&time);
+ } else {
+ *stat_time = 0;
+ }
+}
View
64 test/echo-server.c
@@ -34,6 +34,7 @@ static uv_loop_t* loop;
static int server_closed;
static stream_type serverType;
static uv_tcp_t tcpServer;
+static uv_udp_t udpServer;
static uv_pipe_t pipeServer;
static uv_handle_t* server;
@@ -176,6 +177,34 @@ static void on_server_close(uv_handle_t* handle) {
}
+static void on_send(uv_udp_send_t* req, int status);
+
+
+static void on_recv(uv_udp_t* handle,
+ ssize_t nread,
+ uv_buf_t buf,
+ struct sockaddr* addr,
+ unsigned flags) {
+ uv_udp_send_t* req;
+ int r;
+
+ ASSERT(nread > 0);
+ ASSERT(addr->sa_family == AF_INET);
+
+ req = malloc(sizeof(*req));
+ ASSERT(req != NULL);
+
+ r = uv_udp_send(req, handle, &buf, 1, *(struct sockaddr_in*)addr, on_send);
+ ASSERT(r == 0);
+}
+
+
+static void on_send(uv_udp_send_t* req, int status) {
+ ASSERT(status == 0);
+ free(req);
+}
+
+
static int tcp4_echo_start(int port) {
struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", port);
int r;
@@ -242,6 +271,30 @@ static int tcp6_echo_start(int port) {
}
+static int udp4_echo_start(int port) {
+ int r;
+
+ server = (uv_handle_t*)&udpServer;
+ serverType = UDP;
+
+ r = uv_udp_init(loop, &udpServer);
+ if (r) {
+ fprintf(stderr, "uv_udp_init: %s\n",
+ uv_strerror(uv_last_error(loop)));
+ return 1;
+ }
+
+ r = uv_udp_recv_start(&udpServer, echo_alloc, on_recv);
+ if (r) {
+ fprintf(stderr, "uv_udp_recv_start: %s\n",
+ uv_strerror(uv_last_error(loop)));
+ return 1;
+ }
+
+ return 0;
+}
+
+
static int pipe_echo_start(char* pipeName) {
int r;
@@ -304,3 +357,14 @@ HELPER_IMPL(pipe_echo_server) {
uv_run(loop);
return 0;
}
+
+
+HELPER_IMPL(udp4_echo_server) {
+ loop = uv_default_loop();
+
+ if (udp4_echo_start(TEST_PORT))
+ return 1;
+
+ uv_run(loop);
+ return 0;
+}
View
1  test/task.h
@@ -42,6 +42,7 @@
typedef enum {
TCP = 0,
+ UDP,
PIPE
} stream_type;
View
18 test/test-fs-event.c
@@ -328,21 +328,3 @@ TEST_IMPL(fs_event_immediate_close) {
return 0;
}
-
-
-TEST_IMPL(fs_event_unref) {
- uv_loop_t* loop;
- int r;
-
- loop = uv_default_loop();
-
- r = uv_fs_event_init(loop, &fs_event, ".", fs_event_fail, 0);
- ASSERT(r == 0);
-
- uv_unref(loop);
-
- r = uv_run(loop);
- ASSERT(r == 0);
-
- return 0;
-}
View
46 test/test-list.h
@@ -26,8 +26,6 @@ TEST_DECLARE (ipc_listen_before_write)
TEST_DECLARE (ipc_listen_after_write)
TEST_DECLARE (tcp_ping_pong)
TEST_DECLARE (tcp_ping_pong_v6)
-TEST_DECLARE (tcp_ref)
-TEST_DECLARE (tcp_ref2)
TEST_DECLARE (pipe_ping_pong)
TEST_DECLARE (delayed_accept)
TEST_DECLARE (multiple_listen)
@@ -64,18 +62,29 @@ TEST_DECLARE (shutdown_eof)
TEST_DECLARE (callback_stack)
TEST_DECLARE (error_message)
TEST_DECLARE (timer)
-TEST_DECLARE (timer_ref)
-TEST_DECLARE (timer_ref2)
TEST_DECLARE (timer_again)
TEST_DECLARE (idle_starvation)
TEST_DECLARE (loop_handles)
+TEST_DECLARE (get_loadavg)
TEST_DECLARE (ref)
TEST_DECLARE (idle_ref)
-TEST_DECLARE (get_loadavg)
TEST_DECLARE (async_ref)
TEST_DECLARE (prepare_ref)
TEST_DECLARE (check_ref)
TEST_DECLARE (unref_in_prepare_cb)
+TEST_DECLARE (timer_ref)
+TEST_DECLARE (timer_ref2)
+TEST_DECLARE (fs_event_ref)
+TEST_DECLARE (tcp_ref)
+TEST_DECLARE (tcp_ref2)
+TEST_DECLARE (tcp_ref3)
+TEST_DECLARE (udp_ref)
+TEST_DECLARE (udp_ref2)
+TEST_DECLARE (udp_ref3)
+TEST_DECLARE (pipe_ref)
+TEST_DECLARE (pipe_ref2)
+TEST_DECLARE (pipe_ref3)
+TEST_DECLARE (process_ref)
TEST_DECLARE (async)
TEST_DECLARE (get_currentexe)
TEST_DECLARE (process_title)
@@ -115,7 +124,6 @@ TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
TEST_DECLARE (fs_event_no_callback_on_close)
TEST_DECLARE (fs_event_immediate_close)
-TEST_DECLARE (fs_event_unref)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
@@ -138,6 +146,7 @@ TEST_DECLARE (listen_no_simultaneous_accepts)
#endif
HELPER_DECLARE (tcp4_echo_server)
HELPER_DECLARE (tcp6_echo_server)
+HELPER_DECLARE (udp4_echo_server)
HELPER_DECLARE (pipe_echo_server)
@@ -151,11 +160,6 @@ TASK_LIST_START
TEST_ENTRY (ipc_listen_before_write)
TEST_ENTRY (ipc_listen_after_write)
- TEST_ENTRY (tcp_ref)
-
- TEST_ENTRY (tcp_ref2)
- TEST_HELPER (tcp_ref2, tcp4_echo_server)
-
TEST_ENTRY (tcp_ping_pong)
TEST_HELPER (tcp_ping_pong, tcp4_echo_server)
@@ -212,9 +216,6 @@ TASK_LIST_START
TEST_ENTRY (error_message)
TEST_ENTRY (timer)
- TEST_ENTRY (timer_ref)
- TEST_ENTRY (timer_ref2)
-
TEST_ENTRY (timer_again)
TEST_ENTRY (idle_starvation)
@@ -225,6 +226,22 @@ TASK_LIST_START
TEST_ENTRY (prepare_ref)
TEST_ENTRY (check_ref)
TEST_ENTRY (unref_in_prepare_cb)
+ TEST_ENTRY (timer_ref)
+ TEST_ENTRY (timer_ref2)
+ TEST_ENTRY (fs_event_ref)
+ TEST_ENTRY (tcp_ref)
+ TEST_ENTRY (tcp_ref2)
+ TEST_ENTRY (tcp_ref3)
+ TEST_HELPER (tcp_ref3, tcp4_echo_server)
+ TEST_ENTRY (udp_ref)
+ TEST_ENTRY (udp_ref2)
+ TEST_ENTRY (udp_ref3)
+ TEST_HELPER (udp_ref3, udp4_echo_server)
+ TEST_ENTRY (pipe_ref)
+ TEST_ENTRY (pipe_ref2)
+ TEST_ENTRY (pipe_ref3)
+ TEST_HELPER (pipe_ref3, pipe_echo_server)
+ TEST_ENTRY (process_ref)
TEST_ENTRY (loop_handles)
@@ -284,7 +301,6 @@ TASK_LIST_START
TEST_ENTRY (fs_event_watch_file_current_dir)
TEST_ENTRY (fs_event_no_callback_on_close)
TEST_ENTRY (fs_event_immediate_close)
- TEST_ENTRY (fs_event_unref)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)
View
169 test/test-ref.c
@@ -22,6 +22,14 @@
#include "uv.h"
#include "task.h"
+#include <stdlib.h>
+#include <string.h>
+
+
+static void fail_cb(void) {
+ FATAL("fail_cb should not have been called");
+}
+
TEST_IMPL(ref) {
uv_run(uv_default_loop());
@@ -83,3 +91,164 @@ TEST_IMPL(unref_in_prepare_cb) {
uv_run(uv_default_loop());
return 0;
}
+
+
+TEST_IMPL(timer_ref) {
+ uv_timer_t h;
+ uv_timer_init(uv_default_loop(), &h);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(timer_ref2) {
+ uv_timer_t h;
+ uv_timer_init(uv_default_loop(), &h);
+ uv_timer_start(&h, (uv_timer_cb) fail_cb, 42, 42);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(fs_event_ref) {
+ uv_fs_event_t h;
+ uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb) fail_cb, 0);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(tcp_ref) {
+ uv_tcp_t h;
+ uv_tcp_init(uv_default_loop(), &h);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(tcp_ref2) {
+ uv_tcp_t h;
+ uv_tcp_init(uv_default_loop(), &h);
+ uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(tcp_ref3) {
+ struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
+ uv_connect_t req;
+ uv_tcp_t h;
+ uv_tcp_init(uv_default_loop(), &h);
+ uv_tcp_connect(&req, &h, addr, (uv_connect_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_unref(uv_default_loop()); /* connect req refs the loop */
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(udp_ref) {
+ uv_udp_t h;
+ uv_udp_init(uv_default_loop(), &h);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(udp_ref2) {
+ struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
+ uv_udp_t h;
+ uv_udp_init(uv_default_loop(), &h);
+ uv_udp_bind(&h, addr, 0);
+ uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(udp_ref3) {
+ struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
+ uv_buf_t buf = uv_buf_init("PING", 4);
+ uv_udp_send_t req;
+ uv_udp_t h;
+
+ uv_udp_init(uv_default_loop(), &h);
+ uv_udp_send(&req, &h, &buf, 1, addr, (uv_udp_send_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_unref(uv_default_loop()); /* send req refs the loop */
+ uv_run(uv_default_loop());
+
+ return 0;
+}
+
+
+TEST_IMPL(pipe_ref) {
+ uv_pipe_t h;
+ uv_pipe_init(uv_default_loop(), &h, 0);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(pipe_ref2) {
+ uv_pipe_t h;
+ uv_pipe_init(uv_default_loop(), &h, 0);
+ uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(pipe_ref3) {
+ uv_connect_t req;
+ uv_pipe_t h;
+ uv_pipe_init(uv_default_loop(), &h, 0);
+ uv_pipe_connect(&req, &h, TEST_PIPENAME, (uv_connect_cb)fail_cb);
+ uv_unref(uv_default_loop());
+ uv_unref(uv_default_loop()); /* connect req refs the loop */
+ uv_run(uv_default_loop());
+ return 0;
+}
+
+
+TEST_IMPL(process_ref) {
+ /* spawn_helper4 blocks indefinitely. */
+ char *argv[] = { NULL, "spawn_helper4", NULL };
+ uv_process_options_t options;
+ size_t exepath_size;
+ char exepath[256];
+ uv_process_t h;
+ int r;
+
+ memset(&options, 0, sizeof(options));
+ exepath_size = sizeof(exepath);
+
+ r = uv_exepath(exepath, &exepath_size);
+ ASSERT(r == 0);
+
+ argv[0] = exepath;
+ options.file = exepath;
+ options.args = argv;
+ options.exit_cb = NULL;
+
+ r = uv_spawn(uv_default_loop(), &h, options);
+ ASSERT(r == 0);
+
+ uv_unref(uv_default_loop());
+ uv_run(uv_default_loop());
+
+ r = uv_process_kill(&h, /* SIGTERM */ 15);
+ ASSERT(r == 0);
+
+ return 0;
+}
View
47 test/test-tcp-close.c
@@ -127,50 +127,3 @@ TEST_IMPL(tcp_close) {
return 0;
}
-
-
-TEST_IMPL(tcp_ref) {
- uv_tcp_t never;
- int r;
-
- /* A tcp just initialized should count as one reference. */
- r = uv_tcp_init(uv_default_loop(), &never);
- ASSERT(r == 0);
-
- /* One unref should set the loop ref count to zero. */
- uv_unref(uv_default_loop());
-
- /* Therefore this does not block */
- uv_run(uv_default_loop());
-
- return 0;
-}
-
-
-static void never_cb(uv_connect_t* conn_req, int status) {
- FATAL("never_cb should never be called");
-}
-
-
-TEST_IMPL(tcp_ref2) {
- uv_tcp_t never;
- int r;
-
- /* A tcp just initialized should count as one reference. */
- r = uv_tcp_init(uv_default_loop(), &never);
- ASSERT(r == 0);
-
- r = uv_tcp_connect(&connect_req,
- &never,
- uv_ip4_addr("127.0.0.1", TEST_PORT),
- never_cb);
- ASSERT(r == 0);
-
- /* One unref should set the loop ref count to zero. */
- uv_unref(uv_default_loop());
-
- /* Therefore this does not block */
- uv_run(uv_default_loop());
-
- return 0;
-}
View
40 test/test-timer.c
@@ -130,43 +130,3 @@ TEST_IMPL(timer) {
return 0;
}
-
-
-TEST_IMPL(timer_ref) {
- uv_timer_t never;
- int r;
-
- /* A timer just initialized should count as one reference. */
- r = uv_timer_init(uv_default_loop(), &never);
- ASSERT(r == 0);
-
- /* One unref should set the loop ref count to zero. */
- uv_unref(uv_default_loop());
-
- /* Therefore this does not block */
- uv_run(uv_default_loop());
-
- return 0;
-}
-
-
-TEST_IMPL(timer_ref2) {
- uv_timer_t never;
- int r;
-
- /* A timer just initialized should count as one reference. */
- r = uv_timer_init(uv_default_loop(), &never);
- ASSERT(r == 0);
-
- /* We start the timer, this should not effect the ref count. */
- r = uv_timer_start(&never, never_cb, 1000, 1000);
- ASSERT(r == 0);
-
- /* One unref should set the loop ref count to zero. */
- uv_unref(uv_default_loop());
-
- /* Therefore this does not block */
- uv_run(uv_default_loop());
-
- return 0;
-}
Please sign in to comment.
Something went wrong with that request. Please try again.