servo: Merge #13388 - Avoid a possible deadlock in main_fetch's synchronous code (from servo:deadlock); r=emilio
authorMs2ger <Ms2ger@gmail.com>
Sat, 24 Sep 2016 01:44:09 -0500
changeset 339742 ad944509bfc8073427b4882714801edffb60caea
parent 339741 f80d41a83a964db3f17304c1e20c158dcf2cc1bb
child 339743 83abe34572dac1c84c87e4f2357e30e52e0e7219
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
servo: Merge #13388 - Avoid a possible deadlock in main_fetch's synchronous code (from servo:deadlock); r=emilio 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. Source-Repo: https://github.com/servo/servo Source-Revision: 1d5a05d112fb7063fdcec603da2ddf0cecc0a8ac
servo/components/net/fetch/methods.rs
--- a/servo/components/net/fetch/methods.rs
+++ b/servo/components/net/fetch/methods.rs
@@ -307,25 +307,28 @@ fn main_fetch(request: Rc<Request>, cach
                     Data::Payload(vec) => {
                         if let Some(ref mut target) = *target {
                             target.process_response_chunk(vec);
                         }
                     }
                     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 {
+            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)
             }
-        } else {
-            assert!(*response.body.lock().unwrap() == ResponseBody::Empty)
         }
 
         // overloaded similarly to process_response
         if let Some(ref mut target) = *target {
             target.process_response_eof(&response);
         }
         return response;
     }