Skip to content

Commit

Permalink
fix(upnp): don't panic when gateway is dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Mar 27, 2024
1 parent 5bbec49 commit 9232d80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions protocols/upnp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.2
- Fix a panic caused when `upnp::Gateway` is dropped and its events queue receiver is no longer
available.
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX).

## 0.2.1
- Fix a panic caused when dropping `upnp::Behaviour` such as when used together with `Toggle`.
See [PR 5096](https://github.com/libp2p/rust-libp2p/pull/5096).
Expand Down
2 changes: 1 addition & 1 deletion protocols/upnp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-upnp"
edition = "2021"
rust-version = "1.60.0"
description = "UPnP support for libp2p transports"
version = "0.2.1"
version = "0.2.2"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
Expand Down
8 changes: 4 additions & 4 deletions protocols/upnp/src/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ pub(crate) fn search_gateway() -> oneshot::Receiver<Result<Gateway, Box<dyn Erro
}
}
};
task_sender
.send(event)
.await
.expect("receiver should be available");
// Gateway was dropped.
if let Err(_) = task_sender.send(event).await {

Check failure on line 162 in protocols/upnp/src/tokio.rs

View workflow job for this annotation

GitHub Actions / clippy (1.77.0)

redundant pattern matching, consider using `is_err()`

Check failure on line 162 in protocols/upnp/src/tokio.rs

View workflow job for this annotation

GitHub Actions / clippy (beta)

redundant pattern matching, consider using `is_err()`
return;
}
}
});

Expand Down

0 comments on commit 9232d80

Please sign in to comment.