diff --git a/src/fruity/network-stack.vala b/src/fruity/network-stack.vala index 844469eca..ceff444b1 100644 --- a/src/fruity/network-stack.vala +++ b/src/fruity/network-stack.vala @@ -288,13 +288,13 @@ namespace Frida.Fruity { internal LWIP.ErrorCode perform_on_lwip_thread (owned WorkFunc work) { var req = new Request ((owned) work); - lock (requests) - requests.offer (req); - - if (Thread.self () != lwip_thread) + if (Thread.self () == lwip_thread) { + perform_request (req); + } else { + lock (requests) + requests.offer (req); LWIP.Runtime.schedule (perform_next_request); - else - perform_next_request (); + } return req.join (); } @@ -307,6 +307,10 @@ namespace Frida.Fruity { lock (requests) req = requests.poll (); + perform_request (res); + } + + private void perform_request (Request req) { LWIP.ErrorCode err = req.work (); req.complete (err); }