Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions protocols/upnp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- update igd-next to 0.16.1
See [PR 5944](https://github.com/libp2p/rust-libp2p/pull/5944).

- Fix panic during a shutdown process.
See [PR 5998](https://github.com/libp2p/rust-libp2p/pull/5998).

## 0.4.0

- update igd-next to 0.15.1.
Expand Down
45 changes: 25 additions & 20 deletions protocols/upnp/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,28 +384,33 @@ impl NetworkBehaviour for Behaviour {
loop {
match self.state {
GatewayState::Searching(ref mut fut) => match Pin::new(fut).poll(cx) {
Poll::Ready(result) => {
match result.expect("sender shouldn't have been dropped") {
Ok(gateway) => {
if !is_addr_global(gateway.external_addr) {
self.state =
GatewayState::NonRoutableGateway(gateway.external_addr);
tracing::debug!(
gateway_address=%gateway.external_addr,
"the gateway is not routable"
);
return Poll::Ready(ToSwarm::GenerateEvent(
Event::NonRoutableGateway,
));
}
self.state = GatewayState::Available(gateway);
}
Err(err) => {
tracing::debug!("could not find gateway: {err}");
self.state = GatewayState::GatewayNotFound;
return Poll::Ready(ToSwarm::GenerateEvent(Event::GatewayNotFound));
Poll::Ready(Ok(result)) => match result {
Ok(gateway) => {
if !is_addr_global(gateway.external_addr) {
self.state =
GatewayState::NonRoutableGateway(gateway.external_addr);
tracing::debug!(
gateway_address=%gateway.external_addr,
"the gateway is not routable"
);
return Poll::Ready(ToSwarm::GenerateEvent(
Event::NonRoutableGateway,
));
}
self.state = GatewayState::Available(gateway);
}
Err(err) => {
tracing::debug!("could not find gateway: {err}");
self.state = GatewayState::GatewayNotFound;
return Poll::Ready(ToSwarm::GenerateEvent(Event::GatewayNotFound));
}
},
Poll::Ready(Err(err)) => {
// The sender channel has been dropped. This typically indicates a shutdown
// process is underway.
tracing::debug!("sender has been dropped: {err}");
self.state = GatewayState::GatewayNotFound;
return Poll::Ready(ToSwarm::GenerateEvent(Event::GatewayNotFound));
}
Poll::Pending => return Poll::Pending,
},
Expand Down
Loading