aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-09-23 09:36:02 +0200
committerMs2ger <Ms2ger@gmail.com>2016-09-23 09:36:02 +0200
commitccfd977076ca09aa89de236a55071938a562176b (patch)
treef83a07d22d0680967f6a70bcb2ecc28e842fc3cb
parentfb52bb7c8d70f0d7b85bb35d89779d83a25f2bc2 (diff)
downloadservo-ccfd977076ca09aa89de236a55071938a562176b.tar.gz
servo-ccfd977076ca09aa89de236a55071938a562176b.zip
Avoid a possible deadlock in main_fetch's synchronous code.
On playpen, similar code caused a deadlock on 1.11 stable, and worked fine on nightly 1.13; it seems safer to avoid the pattern entirely.
-rw-r--r--components/net/fetch/methods.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs
index 1f3eb0e5a24..a97ee2e9985 100644
--- a/components/net/fetch/methods.rs
+++ b/components/net/fetch/methods.rs
@@ -312,15 +312,18 @@ fn main_fetch(request: Rc<Request>, cache: &mut CORSCache, cors_flag: bool,
Data::Done => break,
}
}
- } else if let ResponseBody::Done(ref vec) = *response.body.lock().unwrap() {
- // in case there was no channel to wait for, the body was
- // obtained synchronously via basic_fetch for data/file/about/etc
- // We should still send the body across as a chunk
- if let Some(ref mut target) = *target {
- target.process_response_chunk(vec.clone());
- }
} else {
- assert!(*response.body.lock().unwrap() == ResponseBody::Empty)
+ let body = response.body.lock().unwrap();
+ if let ResponseBody::Done(ref vec) = *body {
+ // in case there was no channel to wait for, the body was
+ // obtained synchronously via basic_fetch for data/file/about/etc
+ // We should still send the body across as a chunk
+ if let Some(ref mut target) = *target {
+ target.process_response_chunk(vec.clone());
+ }
+ } else {
+ assert!(*body == ResponseBody::Empty)
+ }
}
// overloaded similarly to process_response