From ca8519cec7ad5b0407d616c7eb57777563bcff35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Fri, 20 Sep 2024 18:59:42 +0200 Subject: [PATCH] network-stack: Fix race in TcpInputStream.read() Where the notify::pending-io signal fires after the call to is_readable() but before our signal handler is connected. --- src/fruity/network-stack.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fruity/network-stack.vala b/src/fruity/network-stack.vala index 18c74e7fa..4dae0a18c 100644 --- a/src/fruity/network-stack.vala +++ b/src/fruity/network-stack.vala @@ -765,10 +765,12 @@ namespace Frida.Fruity { }); } - mutex.lock (); - while (!done) - cond.wait (mutex); - mutex.unlock (); + if (!is_readable ()) { + mutex.lock (); + while (!done) + cond.wait (mutex); + mutex.unlock (); + } if (cancellation_handler != 0) cancellable.disconnect (cancellation_handler);