Jelajahi Sumber

LibCore: Fix race conditions in TestLibCoreStream

It was possible for the "local_socket_read" and "local_socket_write"
tests to fail because we had exited the EventLoop before
BackgroundAction got around to invoking the completion callback.

The crash happened when trying to deferred_invoke() on the background
thread, calling Core::EventLoop::current() after said EventLoop had
returned from exec().

Fix this by not passing a completion callback, since we didn't need
one in the first place.
Andreas Kling 3 tahun lalu
induk
melakukan
5d55a42ded
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 2 2
      Tests/LibCore/TestLibCoreStream.cpp

+ 2 - 2
Tests/LibCore/TestLibCoreStream.cpp

@@ -333,7 +333,7 @@ TEST_CASE(local_socket_read)
 
 
             return 0;
             return 0;
         },
         },
-        [](int) {});
+        nullptr);
 
 
     event_loop.exec();
     event_loop.exec();
     ::unlink("/tmp/test-socket");
     ::unlink("/tmp/test-socket");
@@ -372,7 +372,7 @@ TEST_CASE(local_socket_write)
 
 
             return 0;
             return 0;
         },
         },
-        [](int) {});
+        nullptr);
 
 
     event_loop.exec();
     event_loop.exec();
     ::unlink("/tmp/test-socket");
     ::unlink("/tmp/test-socket");