From 78f24dda037bf7f4350cfefca54a876a0e7ae162 Mon Sep 17 00:00:00 2001 From: cetra3 Date: Thu, 23 Jan 2020 22:32:34 +0000 Subject: [PATCH 1/2] Initial Issue template (#1311) * Initial Issue template * First round of changes for the bug report Co-authored-by: Yuki Okushi --- .github/ISSUE_TEMPLATE/bug_report.md | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..0c4e6c1c6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +Your issue may already be reported! +Please search on the [Actix Web issue tracker](https://github.com/actix/actix-web/issues) before creating one. + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + +## Context + + + +## Your Environment + + +* Rust Version (I.e, output of `rustc -V`): +* Actix Web Version: \ No newline at end of file From 58844874a0e56c51d964ab78f4d426da00541674 Mon Sep 17 00:00:00 2001 From: Maxim Vorobjov Date: Fri, 24 Jan 2020 07:51:38 +0200 Subject: [PATCH 2/2] Fixing #1295 convert UnsafeCell to RefCell in CloneableService (#1303) Co-authored-by: Yuki Okushi --- actix-http/src/cloneable.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/actix-http/src/cloneable.rs b/actix-http/src/cloneable.rs index 65c6bec21..c1dbfa430 100644 --- a/actix-http/src/cloneable.rs +++ b/actix-http/src/cloneable.rs @@ -1,4 +1,4 @@ -use std::cell::UnsafeCell; +use std::cell::RefCell; use std::rc::Rc; use std::task::{Context, Poll}; @@ -6,11 +6,15 @@ use actix_service::Service; #[doc(hidden)] /// Service that allows to turn non-clone service to a service with `Clone` impl -pub(crate) struct CloneableService(Rc>); +/// +/// # Panics +/// CloneableService might panic with some creative use of thread local storage. +/// See https://github.com/actix/actix-web/issues/1295 for example +pub(crate) struct CloneableService(Rc>); impl CloneableService { pub(crate) fn new(service: T) -> Self { - Self(Rc::new(UnsafeCell::new(service))) + Self(Rc::new(RefCell::new(service))) } } @@ -27,10 +31,10 @@ impl Service for CloneableService { type Future = T::Future; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - unsafe { &mut *self.0.as_ref().get() }.poll_ready(cx) + self.0.borrow_mut().poll_ready(cx) } fn call(&mut self, req: T::Request) -> Self::Future { - unsafe { &mut *self.0.as_ref().get() }.call(req) + self.0.borrow_mut().call(req) } }