@@ -288,10 +288,10 @@ static bool waiting_to_close = true;
288
288
289
289
void handle_closed (uv_handle_t * handle) { waiting_to_close = false ; }
290
290
291
- static void really_close (uv_tcp_t * socket ) {
291
+ static void really_close (uv_handle_t * handle ) {
292
292
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);
295
295
SPIN_WHILE (waiting_to_close);
296
296
}
297
297
}
@@ -300,6 +300,7 @@ static void really_close(uv_tcp_t* socket) {
300
300
static void manual_inspector_socket_cleanup () {
301
301
EXPECT_EQ (0 , uv_is_active (
302
302
reinterpret_cast <uv_handle_t *>(&inspector.client )));
303
+ really_close (reinterpret_cast <uv_handle_t *>(&inspector.client ));
303
304
free (inspector.ws_state );
304
305
free (inspector.http_parsing_state );
305
306
free (inspector.buffer );
@@ -339,21 +340,13 @@ class InspectorSocketTest : public ::testing::Test {
339
340
reinterpret_cast <const sockaddr *>(&addr), on_connection);
340
341
uv_tcp_nodelay (&client_socket, 1 ); // The buffering messes up the test
341
342
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));
344
344
}
345
345
346
346
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));
350
349
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);
357
350
expectations* expects = static_cast <expectations*>(inspector.data );
358
351
if (expects != nullptr ) {
359
352
GTEST_ASSERT_EQ (expects->actual_end , expects->actual_offset );
@@ -362,7 +355,11 @@ class InspectorSocketTest : public ::testing::Test {
362
355
free (expects);
363
356
inspector.data = nullptr ;
364
357
}
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);
366
363
}
367
364
};
368
365
0 commit comments