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.
This commit is contained in:
Adrien Destugues 2014-08-04 16:53:20 +02:00
parent a4e5af66f1
commit 7bc2acc216

View File

@ -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;
}