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

Commit

Permalink
Browse files Browse the repository at this point in the history
bring back uv_init
  • Loading branch information
piscisaureus committed Aug 31, 2011
1 parent 56dcaf9 commit 3aec77f
Show file tree
Hide file tree
Showing 31 changed files with 70 additions and 25 deletions.
1 change: 1 addition & 0 deletions include/uv.h
Expand Up @@ -81,6 +81,7 @@ typedef struct uv_work_s uv_work_t;
* All callbacks in libuv are made asynchronously. That is they are never
* made by the function that takes them as a parameter.
*/
void uv_init();
uv_loop_t* uv_loop_new();

void uv_loop_delete(uv_loop_t*);
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-ares.c
Expand Up @@ -84,7 +84,7 @@ BENCHMARK_IMPL(gethostbyname) {
return 1;
}


uv_init();
ares_callbacks = 0;
ares_errors = 0;

Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-getaddrinfo.c
Expand Up @@ -66,7 +66,7 @@ static void getaddrinfo_initiate(uv_getaddrinfo_t* handle) {
BENCHMARK_IMPL(getaddrinfo) {
int i;


uv_init();

uv_update_time();
start_time = uv_now();
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-ping-pongs.c
Expand Up @@ -198,7 +198,7 @@ static void pinger_new() {


BENCHMARK_IMPL(ping_pongs) {

uv_init();
start_time = uv_now();

pinger_new();
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-pound.c
Expand Up @@ -275,7 +275,7 @@ static int pound_it(int concurrency,
uint64_t start_time; /* in ns */
uint64_t end_time;


uv_init();

uv_update_time();
start = uv_now();
Expand Down
8 changes: 4 additions & 4 deletions test/benchmark-pump.c
Expand Up @@ -366,7 +366,7 @@ HELPER_IMPL(tcp_pump_server) {
int r;

type = TCP;

uv_init();
listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT);

/* Server */
Expand All @@ -388,7 +388,7 @@ HELPER_IMPL(pipe_pump_server) {
int r;
type = PIPE;


uv_init();

/* Server */
server = (uv_stream_t*)&pipeServer;
Expand All @@ -410,7 +410,7 @@ void tcp_pump(int n) {
TARGET_CONNECTIONS = n;
type = TCP;


uv_init();

connect_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);

Expand All @@ -426,7 +426,7 @@ void pipe_pump(int n) {
TARGET_CONNECTIONS = n;
type = PIPE;


uv_init();

/* Start making connections */
maybe_connect_some();
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark-spawn.c
Expand Up @@ -130,7 +130,7 @@ BENCHMARK_IMPL(spawn) {
int r;
static int64_t start_time, end_time;


uv_init();

r = uv_exepath(exepath, &exepath_size);
ASSERT(r == 0);
Expand Down
2 changes: 1 addition & 1 deletion test/dns-server.c
Expand Up @@ -314,7 +314,7 @@ static int dns_start(int port) {


HELPER_IMPL(dns_server) {

uv_init();
if (dns_start(TEST_PORT_2))
return 1;

Expand Down
3 changes: 3 additions & 0 deletions test/echo-server.c
Expand Up @@ -270,6 +270,7 @@ static int pipe_echo_start(char* pipeName) {


HELPER_IMPL(tcp4_echo_server) {
uv_init();
uv_loop_t* loop = uv_default_loop();

if (tcp4_echo_start(TEST_PORT))
Expand All @@ -281,6 +282,7 @@ HELPER_IMPL(tcp4_echo_server) {


HELPER_IMPL(tcp6_echo_server) {
uv_init();
uv_loop_t* loop = uv_default_loop();

if (tcp6_echo_start(TEST_PORT))
Expand All @@ -292,6 +294,7 @@ HELPER_IMPL(tcp6_echo_server) {


HELPER_IMPL(pipe_echo_server) {
uv_init();
uv_loop_t* loop = uv_default_loop();

if (pipe_echo_start(TEST_PIPENAME))
Expand Down
2 changes: 2 additions & 0 deletions test/test-async.c
Expand Up @@ -182,6 +182,8 @@ static void prepare_cb(uv_prepare_t* handle, int status) {
TEST_IMPL(async) {
int r;

uv_init();

r = uv_prepare_init(uv_default_loop(), &prepare_handle);
ASSERT(r == 0);
r = uv_prepare_start(&prepare_handle, prepare_cb);
Expand Down
2 changes: 2 additions & 0 deletions test/test-callback-stack.c
Expand Up @@ -176,6 +176,8 @@ static void connect_cb(uv_connect_t* req, int status) {
TEST_IMPL(callback_stack) {
struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT);

uv_init();

if (uv_tcp_init(uv_default_loop(), &client)) {
FATAL("uv_tcp_init failed");
}
Expand Down
3 changes: 2 additions & 1 deletion test/test-connection-fail.c
Expand Up @@ -119,7 +119,7 @@ void connection_fail(uv_connect_cb connect_cb) {
* expect an error.
*/
TEST_IMPL(connection_fail) {

uv_init();

connection_fail(on_connect_with_close);

Expand All @@ -136,6 +136,7 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
TEST_IMPL(connection_fail_doesnt_auto_close) {
uv_init();


uv_timer_init(uv_default_loop(), &timer);
Expand Down
2 changes: 1 addition & 1 deletion test/test-delayed-accept.c
Expand Up @@ -180,7 +180,7 @@ static void client_connect() {


TEST_IMPL(delayed_accept) {

uv_init();

start_server();

Expand Down
3 changes: 2 additions & 1 deletion test/test-getaddrinfo.c
Expand Up @@ -67,6 +67,7 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle,
TEST_IMPL(getaddrinfo_basic) {
int r;

uv_init();


r = uv_getaddrinfo(uv_default_loop(),
Expand All @@ -88,7 +89,7 @@ TEST_IMPL(getaddrinfo_basic) {
TEST_IMPL(getaddrinfo_concurrent) {
int i, r;


uv_init();

for (i = 0; i < CONCURRENT_COUNT; i++) {
callback_counts[i] = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/test-gethostbyname.c
Expand Up @@ -91,7 +91,7 @@ TEST_IMPL(gethostbyname) {
return 1;
}


uv_init();

printf("Start basic gethostbyname test\n");
prep_tcploopback();
Expand Down
4 changes: 2 additions & 2 deletions test/test-getsockname.c
Expand Up @@ -288,7 +288,7 @@ static void udp_sender(void) {


TEST_IMPL(getsockname_tcp) {

uv_init();

if (tcp_listener(TEST_PORT))
return 1;
Expand Down Expand Up @@ -316,4 +316,4 @@ TEST_IMPL(getsockname_udp) {
ASSERT(getsocknamecount == 2);

return 0;
}
}
1 change: 1 addition & 0 deletions test/test-idle.c
Expand Up @@ -60,6 +60,7 @@ static void idle_cb(uv_idle_t* handle, int status) {
TEST_IMPL(idle_starvation) {
int r;

uv_init();


r = uv_idle_init(uv_default_loop(), &idle_handle);
Expand Down
1 change: 1 addition & 0 deletions test/test-loop-handles.c
Expand Up @@ -299,6 +299,7 @@ TEST_IMPL(loop_handles) {
int i;
int r;

uv_init();


r = uv_prepare_init(uv_default_loop(), &prepare_1_handle);
Expand Down
6 changes: 3 additions & 3 deletions test/test-ping-pong.c
Expand Up @@ -221,7 +221,7 @@ static void pipe_pinger_new() {


TEST_IMPL(tcp_ping_pong) {

uv_init();

tcp_pinger_new();
uv_run(uv_default_loop());
Expand All @@ -233,7 +233,7 @@ TEST_IMPL(tcp_ping_pong) {


TEST_IMPL(tcp_ping_pong_v6) {

uv_init();

tcp_pinger_v6_new();
uv_run(uv_default_loop());
Expand All @@ -245,7 +245,7 @@ TEST_IMPL(tcp_ping_pong_v6) {


TEST_IMPL(pipe_ping_pong) {

uv_init();

pipe_pinger_new();
uv_run(uv_default_loop());
Expand Down
4 changes: 4 additions & 0 deletions test/test-pipe-bind-error.c
Expand Up @@ -45,6 +45,7 @@ TEST_IMPL(pipe_bind_error_addrinuse) {
uv_pipe_t server1, server2;
int r;

uv_init();


r = uv_pipe_init(uv_default_loop(), &server1);
Expand Down Expand Up @@ -81,6 +82,7 @@ TEST_IMPL(pipe_bind_error_addrnotavail) {
uv_pipe_t server;
int r;

uv_init();


r = uv_pipe_init(uv_default_loop(), &server);
Expand All @@ -104,6 +106,7 @@ TEST_IMPL(pipe_bind_error_inval) {
uv_pipe_t server;
int r;

uv_init();


r = uv_pipe_init(uv_default_loop(), &server);
Expand All @@ -129,6 +132,7 @@ TEST_IMPL(pipe_listen_without_bind) {
uv_pipe_t server;
int r;

uv_init();


r = uv_pipe_init(uv_default_loop(), &server);
Expand Down
6 changes: 6 additions & 0 deletions test/test-ref.c
Expand Up @@ -24,13 +24,15 @@


TEST_IMPL(ref) {
uv_init();
uv_run(uv_default_loop());
return 0;
}


TEST_IMPL(idle_ref) {
uv_idle_t h;
uv_init();
uv_idle_init(uv_default_loop(), &h);
uv_idle_start(&h, NULL);
uv_unref(uv_default_loop());
Expand All @@ -41,6 +43,7 @@ TEST_IMPL(idle_ref) {

TEST_IMPL(async_ref) {
uv_async_t h;
uv_init();
uv_async_init(uv_default_loop(), &h, NULL);
uv_unref(uv_default_loop());
uv_run(uv_default_loop());
Expand All @@ -50,6 +53,7 @@ TEST_IMPL(async_ref) {

TEST_IMPL(prepare_ref) {
uv_prepare_t h;
uv_init();
uv_prepare_init(uv_default_loop(), &h);
uv_prepare_start(&h, NULL);
uv_unref(uv_default_loop());
Expand All @@ -60,6 +64,7 @@ TEST_IMPL(prepare_ref) {

TEST_IMPL(check_ref) {
uv_check_t h;
uv_init();
uv_check_init(uv_default_loop(), &h);
uv_check_start(&h, NULL);
uv_unref(uv_default_loop());
Expand All @@ -78,6 +83,7 @@ static void prepare_cb(uv_prepare_t* handle, int status) {

TEST_IMPL(unref_in_prepare_cb) {
uv_prepare_t h;
uv_init();

uv_prepare_init(uv_default_loop(), &h);
uv_prepare_start(&h, prepare_cb);
Expand Down
2 changes: 1 addition & 1 deletion test/test-shutdown-eof.c
Expand Up @@ -153,7 +153,7 @@ TEST_IMPL(shutdown_eof) {
struct sockaddr_in server_addr;
int r;


uv_init();

qbuf.base = "Q";
qbuf.len = 1;
Expand Down
10 changes: 5 additions & 5 deletions test/test-spawn.c
Expand Up @@ -116,7 +116,7 @@ static void timer_cb(uv_timer_t* handle, int status) {
TEST_IMPL(spawn_exit_code) {
int r;


uv_init();

init_process_options("spawn_helper1", exit_cb);

Expand All @@ -137,7 +137,7 @@ TEST_IMPL(spawn_stdout) {
int r;
uv_pipe_t out;


uv_init();

init_process_options("spawn_helper2", exit_cb);

Expand Down Expand Up @@ -170,7 +170,7 @@ int r;
uv_buf_t buf;
char buffer[] = "hello-from-spawn_stdin";


uv_init();

init_process_options("spawn_helper3", exit_cb);

Expand Down Expand Up @@ -204,7 +204,7 @@ int r;
TEST_IMPL(spawn_and_kill) {
int r;


uv_init();

init_process_options("spawn_helper4", kill_cb);

Expand Down Expand Up @@ -234,7 +234,7 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
char name[64];
HANDLE pipe_handle;


uv_init();

init_process_options("spawn_helper2", exit_cb);

Expand Down

0 comments on commit 3aec77f

Please sign in to comment.