test: fix close of uninitialized handle

The test closes all handles after 1000 ms but the remote peer handle may not
have been initialized by then (very unlikely but not quite impossible).
This commit is contained in:
Ben Noordhuis 2012-11-11 01:16:51 +01:00
parent 0a7e36dcf1
commit 625340066e

View File

@ -77,7 +77,6 @@ static void connection_cb(uv_stream_t* handle, int status) {
buf = uv_buf_init("PING", 4);
ASSERT(0 == status);
ASSERT(0 == uv_tcp_init(uv_default_loop(), &peer_handle));
ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle));
ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb));
ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &peer_handle,
@ -98,6 +97,7 @@ TEST_IMPL(tcp_unexpected_read) {
ASSERT(0 == uv_check_start(&check_handle, check_cb));
ASSERT(0 == uv_tcp_init(loop, &server_handle));
ASSERT(0 == uv_tcp_init(loop, &client_handle));
ASSERT(0 == uv_tcp_init(loop, &peer_handle));
ASSERT(0 == uv_tcp_bind(&server_handle, addr));
ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb));
ASSERT(0 == uv_tcp_connect(&connect_req, &client_handle, addr, connect_cb));