@@ -288,10 +288,10 @@ static bool waiting_to_close = true;
288288
289289void handle_closed (uv_handle_t * handle) { waiting_to_close = false ; }
290290
291- static void really_close (uv_tcp_t * socket ) {
291+ static void really_close (uv_handle_t * handle ) {
292292 waiting_to_close = true ;
293- if (!uv_is_closing (reinterpret_cast < uv_handle_t *>(socket) )) {
294- uv_close (reinterpret_cast < uv_handle_t *>(socket) , handle_closed);
293+ if (!uv_is_closing (handle )) {
294+ uv_close (handle , handle_closed);
295295 SPIN_WHILE (waiting_to_close);
296296 }
297297}
@@ -300,6 +300,7 @@ static void really_close(uv_tcp_t* socket) {
300300static void manual_inspector_socket_cleanup () {
301301 EXPECT_EQ (0 , uv_is_active (
302302 reinterpret_cast <uv_handle_t *>(&inspector.client )));
303+ really_close (reinterpret_cast <uv_handle_t *>(&inspector.client ));
303304 free (inspector.ws_state );
304305 free (inspector.http_parsing_state );
305306 free (inspector.buffer );
@@ -339,21 +340,13 @@ class InspectorSocketTest : public ::testing::Test {
339340 reinterpret_cast <const sockaddr *>(&addr), on_connection);
340341 uv_tcp_nodelay (&client_socket, 1 ); // The buffering messes up the test
341342 SPIN_WHILE (!connect.data || !connected);
342- really_close (&server);
343- uv_unref (reinterpret_cast <uv_handle_t *>(&server));
343+ really_close (reinterpret_cast <uv_handle_t *>(&server));
344344 }
345345
346346 virtual void TearDown () {
347- really_close (&client_socket);
348- for (int i = 0 ; i < MAX_LOOP_ITERATIONS; i++)
349- uv_run (&loop, UV_RUN_NOWAIT);
347+ really_close (reinterpret_cast <uv_handle_t *>(&client_socket));
348+ really_close (reinterpret_cast <uv_handle_t *>(&timeout_timer));
350349 EXPECT_EQ (nullptr , inspector.buffer );
351- uv_stop (&loop);
352- int err = uv_run (&loop, UV_RUN_ONCE);
353- if (err != 0 ) {
354- uv_print_active_handles (&loop, stderr);
355- }
356- EXPECT_EQ (0 , err);
357350 expectations* expects = static_cast <expectations*>(inspector.data );
358351 if (expects != nullptr ) {
359352 GTEST_ASSERT_EQ (expects->actual_end , expects->actual_offset );
@@ -362,7 +355,11 @@ class InspectorSocketTest : public ::testing::Test {
362355 free (expects);
363356 inspector.data = nullptr ;
364357 }
365- uv_loop_close (&loop);
358+ const int err = uv_loop_close (&loop);
359+ if (err != 0 ) {
360+ uv_print_all_handles (&loop, stderr);
361+ }
362+ EXPECT_EQ (0 , err);
366363 }
367364};
368365
0 commit comments