Skip to content

Commit

Permalink
fix(awc): prevent panics in pool drop for h1 connections
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Aug 18, 2024
1 parent 538c1be commit c057605
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions awc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Prevent panics on connection pool drop when Tokio runtime is shutdown early.

## 3.5.1

- Fix WebSocket `Host` request header value when using a non-default port.
Expand Down
4 changes: 3 additions & 1 deletion awc/src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ where
fn close(&self, conn: ConnectionInnerType<Io>) {
if let Some(timeout) = self.config.disconnect_timeout {
if let ConnectionInnerType::H1(io) = conn {
actix_rt::spawn(CloseConnection::new(io, timeout));
if tokio::runtime::Handle::try_current().is_ok() {
actix_rt::spawn(CloseConnection::new(io, timeout));
}
}
}
}
Expand Down

0 comments on commit c057605

Please sign in to comment.