diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 4b53161a..3024703d 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -4,8 +4,11 @@ ### Fixed +* awc client panic #1016 + * Invalid response with compression middleware enabled, but compression-related features disabled #997 + ## [0.2.7] - 2019-07-18 ### Added diff --git a/actix-http/src/client/pool.rs b/actix-http/src/client/pool.rs index 4739141d..dbd8f202 100644 --- a/actix-http/src/client/pool.rs +++ b/actix-http/src/client/pool.rs @@ -305,10 +305,12 @@ pub(crate) struct Inner { limit: usize, acquired: usize, available: HashMap>>, - waiters: Slab<( - Connect, - oneshot::Sender, ConnectError>>, - )>, + waiters: Slab< + Option<( + Connect, + oneshot::Sender, ConnectError>>, + )>, + >, waiters_queue: IndexSet<(Key, usize)>, task: Option, } @@ -346,7 +348,7 @@ where let key: Key = connect.uri.authority_part().unwrap().clone().into(); let entry = self.waiters.vacant_entry(); let token = entry.key(); - entry.insert((connect, tx)); + entry.insert(Some((connect, tx))); assert!(self.waiters_queue.insert((key, token))); (rx, token, self.task.is_some()) @@ -499,10 +501,14 @@ where break; } }; + if inner.waiters.get(token).unwrap().is_none() { + continue; + } + match inner.acquire(&key) { Acquire::NotAvailable => break, Acquire::Acquired(io, created) => { - let (_, tx) = inner.waiters.remove(token); + let tx = inner.waiters.get_mut(token).unwrap().take().unwrap().1; if let Err(conn) = tx.send(Ok(IoConnection::new( io, created, @@ -513,7 +519,8 @@ where } } Acquire::Available => { - let (connect, tx) = inner.waiters.remove(token); + let (connect, tx) = + inner.waiters.get_mut(token).unwrap().take().unwrap(); OpenWaitingConnection::spawn( key.clone(), tx,