From 625340066ebad876bb46ff3165b3b6fb23168dc0 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 11 Nov 2012 01:16:51 +0100 Subject: [PATCH] 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). --- test/test-tcp-unexpected-read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-tcp-unexpected-read.c b/test/test-tcp-unexpected-read.c index 772746bc..71db558d 100644 --- a/test/test-tcp-unexpected-read.c +++ b/test/test-tcp-unexpected-read.c @@ -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));