forked from cory/tildefriends
libuv 1.47.0.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4615 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@@ -48,10 +48,10 @@ static void on_client_connect(uv_connect_t* conn_req, int status) {
|
||||
int r;
|
||||
|
||||
r = uv_read_start((uv_stream_t*) &client, on_client_alloc, on_client_read);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_timer_start(&timer, on_client_timeout, 1000, 0);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ static void on_client_read(uv_stream_t* stream, ssize_t nread,
|
||||
|
||||
|
||||
static void on_client_timeout(uv_timer_t* handle) {
|
||||
ASSERT_EQ(handle, &timer);
|
||||
ASSERT_EQ(read_cb_called, 0);
|
||||
ASSERT_PTR_EQ(handle, &timer);
|
||||
ASSERT_OK(read_cb_called);
|
||||
uv_read_stop((uv_stream_t*) &client);
|
||||
uv_close((uv_handle_t*) &client, on_close);
|
||||
uv_close((uv_handle_t*) &timer, on_close);
|
||||
@@ -101,20 +101,20 @@ static void on_connection_read(uv_stream_t* stream,
|
||||
static void on_connection(uv_stream_t* server, int status) {
|
||||
int r;
|
||||
|
||||
ASSERT_EQ(status, 0);
|
||||
ASSERT_EQ(uv_accept(server, (uv_stream_t*) &connection), 0);
|
||||
ASSERT_OK(status);
|
||||
ASSERT_OK(uv_accept(server, (uv_stream_t*) &connection));
|
||||
|
||||
r = uv_read_start((uv_stream_t*) &connection,
|
||||
on_connection_alloc,
|
||||
on_connection_read);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
}
|
||||
|
||||
|
||||
static void on_close(uv_handle_t* handle) {
|
||||
ASSERT(handle == (uv_handle_t*) &client ||
|
||||
handle == (uv_handle_t*) &connection ||
|
||||
handle == (uv_handle_t*) &timer);
|
||||
ASSERT_NE(handle == (uv_handle_t*) &client ||
|
||||
handle == (uv_handle_t*) &connection ||
|
||||
handle == (uv_handle_t*) &timer, 0);
|
||||
on_close_called++;
|
||||
}
|
||||
|
||||
@@ -123,16 +123,16 @@ static void start_server(uv_loop_t* loop, uv_tcp_t* handle) {
|
||||
struct sockaddr_in addr;
|
||||
int r;
|
||||
|
||||
ASSERT_EQ(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr), 0);
|
||||
ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||
|
||||
r = uv_tcp_init(loop, handle);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_tcp_bind(handle, (const struct sockaddr*) &addr, 0);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_listen((uv_stream_t*) handle, 128, on_connection);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
uv_unref((uv_handle_t*) handle);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ TEST_IMPL(tcp_close_after_read_timeout) {
|
||||
uv_loop_t* loop;
|
||||
int r;
|
||||
|
||||
ASSERT_EQ(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr), 0);
|
||||
ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||
|
||||
loop = uv_default_loop();
|
||||
|
||||
@@ -155,28 +155,28 @@ TEST_IMPL(tcp_close_after_read_timeout) {
|
||||
start_server(loop, &tcp_server);
|
||||
|
||||
r = uv_tcp_init(loop, &client);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_tcp_connect(&connect_req,
|
||||
&client,
|
||||
(const struct sockaddr*) &addr,
|
||||
on_client_connect);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_tcp_init(loop, &connection);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
r = uv_timer_init(loop, &timer);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
ASSERT_EQ(read_cb_called, 0);
|
||||
ASSERT_EQ(on_close_called, 0);
|
||||
ASSERT_OK(read_cb_called);
|
||||
ASSERT_OK(on_close_called);
|
||||
|
||||
r = uv_run(loop, UV_RUN_DEFAULT);
|
||||
ASSERT_EQ(r, 0);
|
||||
ASSERT_OK(r);
|
||||
|
||||
ASSERT_EQ(read_cb_called, 1);
|
||||
ASSERT_EQ(on_close_called, 3);
|
||||
ASSERT_EQ(1, read_cb_called);
|
||||
ASSERT_EQ(3, on_close_called);
|
||||
|
||||
MAKE_VALGRIND_HAPPY(loop);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user