From 5d531989e70d6279ea97e7dead7a1feae3240abc Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 23 Apr 2019 09:42:19 -0700 Subject: [PATCH] Fix BorrowMutError panic in client connector #793 --- actix-http/CHANGES.md | 7 +++++++ actix-http/src/client/pool.rs | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index fc33ff411..2edcceeb0 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.1.2] - 2019-04-23 + +### Fixed + +* Fix BorrowMutError panic in client connector #793 + + ## [0.1.1] - 2019-04-19 ### Changes diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 7b138dbaa..1164205ea 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -113,31 +113,31 @@ where match self.1.as_ref().borrow_mut().acquire(&key) { Acquire::Acquired(io, created) => { // use existing connection - Either::A(ok(IoConnection::new( + return Either::A(ok(IoConnection::new( io, created, Some(Acquired(key, Some(self.1.clone()))), - ))) - } - Acquire::NotAvailable => { - // connection is not available, wait - let (rx, token) = self.1.as_ref().borrow_mut().wait_for(req); - Either::B(Either::A(WaitForConnection { - rx, - key, - token, - inner: Some(self.1.clone()), - })) + ))); } Acquire::Available => { // open new connection - Either::B(Either::B(OpenConnection::new( + return Either::B(Either::B(OpenConnection::new( key, self.1.clone(), self.0.call(req), - ))) + ))); } + _ => (), } + + // connection is not available, wait + let (rx, token) = self.1.as_ref().borrow_mut().wait_for(req); + Either::B(Either::A(WaitForConnection { + rx, + key, + token, + inner: Some(self.1.clone()), + })) } }