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 4ba03dd
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jan 16, 2013
1 parent 47f3fc9 commit 952e42d
Show file tree
Hide file tree
Showing 85 changed files with 230 additions and 429 deletions.
8 changes: 1 addition & 7 deletions deps/uv/include/uv.h
Expand Up @@ -244,12 +244,6 @@ UV_EXTERN void uv_loop_delete(uv_loop_t*);
*/
UV_EXTERN uv_loop_t* uv_default_loop(void);

/*
* This function starts the event loop. It blocks until the reference count
* of the loop drops to zero. Always returns zero.
*/
UV_EXTERN int uv_run(uv_loop_t*);

/*
* This function runs the event loop. It will act differently depending on the
* specified mode:
Expand All @@ -262,7 +256,7 @@ UV_EXTERN int uv_run(uv_loop_t*);
* - UV_RUN_NOWAIT: Poll for new events once but don't block if there are no
* pending events.
*/
UV_EXTERN int uv_run2(uv_loop_t*, uv_run_mode mode);
UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);

/*
* Manually modify the event loop's reference count. Useful if the user wants
Expand Down
7 changes: 1 addition & 6 deletions deps/uv/src/unix/core.c
Expand Up @@ -279,7 +279,7 @@ static int uv__loop_alive(uv_loop_t* loop) {
}


int uv_run2(uv_loop_t* loop, uv_run_mode mode) {
int uv_run(uv_loop_t* loop, uv_run_mode mode) {
int r;

if (!uv__loop_alive(loop))
Expand All @@ -301,11 +301,6 @@ int uv_run2(uv_loop_t* loop, uv_run_mode mode) {
}


int uv_run(uv_loop_t* loop) {
return uv_run2(loop, UV_RUN_DEFAULT);
}


void uv_update_time(uv_loop_t* loop) {
uv__update_time(loop);
}
Expand Down
41 changes: 15 additions & 26 deletions deps/uv/src/unix/stream.c
Expand Up @@ -926,6 +926,14 @@ static void uv__read(uv_stream_t* stream) {
while (nread < 0 && errno == EINTR);
}

#define INVOKE_READ_CB(stream, status, buf, type) \
do { \
if ((stream)->read_cb != NULL) \
(stream)->read_cb((stream), (status), (buf)); \
else \
(stream)->read2_cb((uv_pipe_t*) (stream), (status), (buf), (type)); \
} \
while (0)

if (nread < 0) {
/* Error */
Expand All @@ -935,41 +943,22 @@ static void uv__read(uv_stream_t* stream) {
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN);
}
uv__set_sys_error(stream->loop, EAGAIN);

if (stream->read_cb) {
stream->read_cb(stream, 0, buf);
} else {
stream->read2_cb((uv_pipe_t*)stream, 0, buf, UV_UNKNOWN_HANDLE);
}

return;
INVOKE_READ_CB(stream, 0, buf, UV_UNKNOWN_HANDLE);
} else {
/* Error. User should call uv_close(). */
uv__set_sys_error(stream->loop, errno);

if (stream->read_cb) {
stream->read_cb(stream, -1, buf);
} else {
stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
}

assert(!uv__io_active(&stream->io_watcher, UV__POLLIN));
return;
INVOKE_READ_CB(stream, -1, buf, UV_UNKNOWN_HANDLE);
assert(!uv__io_active(&stream->io_watcher, UV__POLLIN) &&
"stream->read_cb(status=-1) did not call uv_close()");
}

return;
} else if (nread == 0) {
/* EOF */
uv__set_artificial_error(stream->loop, UV_EOF);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);

if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
uv__handle_stop(stream);

if (stream->read_cb) {
stream->read_cb(stream, -1, buf);
} else {
stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
}
uv__set_artificial_error(stream->loop, UV_EOF);
INVOKE_READ_CB(stream, -1, buf, UV_UNKNOWN_HANDLE);
return;
} else {
/* Successful read */
Expand Down
7 changes: 1 addition & 6 deletions deps/uv/src/win/core.c
Expand Up @@ -252,7 +252,7 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
!ngx_queue_empty(&(loop)->active_reqs) || \
(loop)->endgame_handles != NULL)

int uv_run2(uv_loop_t *loop, uv_run_mode mode) {
int uv_run(uv_loop_t *loop, uv_run_mode mode) {
int r;
void (*poll)(uv_loop_t* loop, int block);

Expand Down Expand Up @@ -291,8 +291,3 @@ int uv_run2(uv_loop_t *loop, uv_run_mode mode) {
}
return r;
}


int uv_run(uv_loop_t* loop) {
return uv_run2(loop, UV_RUN_DEFAULT);
}
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-async-pummel.c
Expand Up @@ -78,7 +78,7 @@ static int test_async_pummel(int nthreads) {

time = uv_hrtime();

ASSERT(0 == uv_run(uv_default_loop()));
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));

time = uv_hrtime() - time;
done = 1;
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/test/benchmark-async.c
Expand Up @@ -67,7 +67,7 @@ static void main_async_cb(uv_async_t* handle, int status) {
static void worker(void* arg) {
struct ctx* ctx = arg;
ASSERT(0 == uv_async_send(&ctx->main_async));
ASSERT(0 == uv_run(ctx->loop));
ASSERT(0 == uv_run(ctx->loop, UV_RUN_DEFAULT));
}


Expand All @@ -92,7 +92,7 @@ static int test_async(int nthreads) {

time = uv_hrtime();

ASSERT(0 == uv_run(uv_default_loop()));
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));

for (i = 0; i < nthreads; i++)
ASSERT(0 == uv_thread_join(&threads[i].thread));
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/test/benchmark-fs-stat.c
Expand Up @@ -51,7 +51,7 @@ static void warmup(const char* path) {
for (i = 0; i < ARRAY_SIZE(reqs); i++)
uv_fs_stat(uv_default_loop(), reqs + i, path, uv_fs_req_cleanup);

uv_run(uv_default_loop());
uv_run(uv_default_loop(), UV_RUN_DEFAULT);

/* warm up the OS dirent cache */
for (i = 0; i < 16; i++)
Expand Down Expand Up @@ -108,7 +108,7 @@ static void async_bench(const char* path) {
}

before = uv_hrtime();
uv_run(uv_default_loop());
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
after = uv_hrtime();

printf("%s stats (%d concurrent): %.2fs (%s/s)\n",
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-getaddrinfo.c
Expand Up @@ -75,7 +75,7 @@ BENCHMARK_IMPL(getaddrinfo) {
getaddrinfo_initiate(&handles[i]);
}

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

uv_update_time(loop);
end_time = uv_now(loop);
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/test/benchmark-loop-count.c
Expand Up @@ -57,7 +57,7 @@ BENCHMARK_IMPL(loop_count) {
uv_idle_start(&idle_handle, idle_cb);

ns = uv_hrtime();
uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
ns = uv_hrtime() - ns;

ASSERT(ticks == NUM_TICKS);
Expand All @@ -81,7 +81,7 @@ BENCHMARK_IMPL(loop_count_timed) {
uv_timer_init(loop, &timer_handle);
uv_timer_start(&timer_handle, timer_cb, 5000, 0);

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

LOGF("loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0);

Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-million-async.c
Expand Up @@ -99,7 +99,7 @@ BENCHMARK_IMPL(million_async) {
ASSERT(0 == uv_timer_init(loop, &timer_handle));
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, timeout, 0));
ASSERT(0 == uv_thread_create(&thread_id, thread_cb, NULL));
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
printf("%s async events in %.1f seconds (%s/s, %s unique handles seen)\n",
fmt(container->async_events),
timeout / 1000.,
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/test/benchmark-million-timers.c
Expand Up @@ -59,13 +59,13 @@ BENCHMARK_IMPL(million_timers) {
}

before = uv_hrtime();
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
after = uv_hrtime();

for (i = 0; i < NUM_TIMERS; i++)
uv_close((uv_handle_t*) (timers + i), close_cb);

ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
ASSERT(timer_cb_called == NUM_TIMERS);
ASSERT(close_cb_called == NUM_TIMERS);
free(timers);
Expand Down
10 changes: 5 additions & 5 deletions deps/uv/test/benchmark-multi-accept.c
Expand Up @@ -214,9 +214,9 @@ static void send_listen_handles(uv_handle_type type,
for (i = 0; i < num_servers; i++)
uv_sem_post(&servers[i].semaphore);

ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
uv_close((uv_handle_t*) &ctx.server_handle, NULL);
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));

for (i = 0; i < num_servers; i++)
uv_sem_wait(&servers[i].semaphore);
Expand All @@ -234,7 +234,7 @@ static void get_listen_handle(uv_loop_t* loop, uv_stream_t* server_handle) {
&ctx.ipc_pipe,
IPC_PIPE_NAME,
ipc_connect_cb);
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
}


Expand All @@ -258,7 +258,7 @@ static void server_cb(void *arg) {
ASSERT(0 == uv_listen((uv_stream_t*) &ctx->server_handle,
128,
sv_connection_cb));
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));

uv_loop_delete(loop);
}
Expand Down Expand Up @@ -383,7 +383,7 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) {

{
uint64_t t = uv_hrtime();
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
t = uv_hrtime() - t;
time = t / 1e9;
}
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-ping-pongs.c
Expand Up @@ -203,7 +203,7 @@ BENCHMARK_IMPL(ping_pongs) {
start_time = uv_now(loop);

pinger_new();
uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

ASSERT(completed_pingers == 1);

Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-pound.c
Expand Up @@ -287,7 +287,7 @@ static int pound_it(int concurrency,
r = do_connect(concurrency, make_connect, arg);
ASSERT(!r);

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

end_time = uv_hrtime();

Expand Down
8 changes: 4 additions & 4 deletions deps/uv/test/benchmark-pump.c
Expand Up @@ -373,7 +373,7 @@ HELPER_IMPL(tcp_pump_server) {
r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

return 0;
}
Expand All @@ -394,7 +394,7 @@ HELPER_IMPL(pipe_pump_server) {
r = uv_listen((uv_stream_t*)&pipeServer, MAX_WRITE_HANDLES, connection_cb);
ASSERT(r == 0);

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

MAKE_VALGRIND_HAPPY();
return 0;
Expand All @@ -413,7 +413,7 @@ static void tcp_pump(int n) {
/* Start making connections */
maybe_connect_some();

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

MAKE_VALGRIND_HAPPY();
}
Expand All @@ -429,7 +429,7 @@ static void pipe_pump(int n) {
/* Start making connections */
maybe_connect_some();

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);

MAKE_VALGRIND_HAPPY();
}
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-spawn.c
Expand Up @@ -149,7 +149,7 @@ BENCHMARK_IMPL(spawn) {

spawn();

r = uv_run(loop);
r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);

uv_update_time(loop);
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-tcp-write-batch.c
Expand Up @@ -122,7 +122,7 @@ BENCHMARK_IMPL(tcp_write_batch) {

start = uv_hrtime();

r = uv_run(loop);
r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(r == 0);

stop = uv_hrtime();
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/benchmark-udp-pummel.c
Expand Up @@ -195,7 +195,7 @@ static int pummel(unsigned int n_senders,
}

duration = uv_hrtime();
ASSERT(0 == uv_run(loop));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
duration = uv_hrtime() - duration;
/* convert from nanoseconds to milliseconds */
duration = duration / (uint64_t) 1e6;
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/blackhole-server.c
Expand Up @@ -111,7 +111,7 @@ HELPER_IMPL(tcp4_blackhole_server) {
r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb);
ASSERT(r == 0);

r = uv_run(loop);
r = uv_run(loop, UV_RUN_DEFAULT);
ASSERT(0 && "Blackhole server dropped out of event loop.");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion deps/uv/test/dns-server.c
Expand Up @@ -324,6 +324,6 @@ HELPER_IMPL(dns_server) {
if (dns_start(TEST_PORT_2))
return 1;

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
8 changes: 4 additions & 4 deletions deps/uv/test/echo-server.c
Expand Up @@ -346,7 +346,7 @@ HELPER_IMPL(tcp4_echo_server) {
if (tcp4_echo_start(TEST_PORT))
return 1;

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}

Expand All @@ -357,7 +357,7 @@ HELPER_IMPL(tcp6_echo_server) {
if (tcp6_echo_start(TEST_PORT))
return 1;

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}

Expand All @@ -368,7 +368,7 @@ HELPER_IMPL(pipe_echo_server) {
if (pipe_echo_start(TEST_PIPENAME))
return 1;

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}

Expand All @@ -379,6 +379,6 @@ HELPER_IMPL(udp4_echo_server) {
if (udp4_echo_start(TEST_PORT))
return 1;

uv_run(loop);
uv_run(loop, UV_RUN_DEFAULT);
return 0;
}

0 comments on commit 952e42d

Please sign in to comment.