From 7bc2acc216c7e4dcfe0f3b552dfd3bcca1b74ab9 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 4 Aug 2014 16:53:20 +0200 Subject: [PATCH] UrlRequest: fix race condition * The thread could set fRunning to false before the caller had set it to true, leading to a stalled request. * Happened easily when testing "data" requests, which are fast since no I/O is involved. * Possibly also helps with stalled redirects on Google search I've been seeing for some time. --- src/kits/network/libnetapi/UrlRequest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kits/network/libnetapi/UrlRequest.cpp b/src/kits/network/libnetapi/UrlRequest.cpp index 51dc7a0f46..35bb8a55f1 100644 --- a/src/kits/network/libnetapi/UrlRequest.cpp +++ b/src/kits/network/libnetapi/UrlRequest.cpp @@ -53,6 +53,8 @@ BUrlRequest::Run() if (fThreadId < B_OK) return fThreadId; + fRunning = true; + status_t launchErr = resume_thread(fThreadId); if (launchErr < B_OK) { PRINT(("BUrlRequest::Run() : Failed to resume thread %" B_PRId32 "\n", @@ -60,7 +62,6 @@ BUrlRequest::Run() return launchErr; } - fRunning = true; return fThreadId; }