diff --git a/actix-http/src/message.rs b/actix-http/src/message.rs index 5e53f73b6..3673017bc 100644 --- a/actix-http/src/message.rs +++ b/actix-http/src/message.rs @@ -67,7 +67,7 @@ impl Head for RequestHead { fn clear(&mut self) { self.flags = Flags::empty(); self.headers.clear(); - self.extensions.borrow_mut().clear(); + self.extensions.get_mut().clear(); } fn pool() -> &'static MessagePool { @@ -440,9 +440,11 @@ impl MessagePool { #[inline] fn get_message(&'static self) -> Message { if let Some(mut msg) = self.0.borrow_mut().pop() { - if let Some(r) = Rc::get_mut(&mut msg) { - r.clear(); - } + // Message is put in pool only when it's the last copy. + // which means it's guaranteed to be unique when popped out. + Rc::get_mut(&mut msg) + .expect("Multiple copies exist") + .clear(); Message { head: msg } } else { Message {