Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the error to inject_listener_closed method #1517

Merged
merged 5 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 2 deletions swarm/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub trait NetworkBehaviour: Send + 'static {
}

/// A listener closed.
fn inject_listener_closed(&mut self, _id: ListenerId) {
fn inject_listener_closed(&mut self, _id: ListenerId, _err: Option<std::io::Error>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you leave the Result for consistency with the rest of the library?

Suggested change
fn inject_listener_closed(&mut self, _id: ListenerId, _err: Option<std::io::Error>) {
fn inject_listener_closed(&mut self, _id: ListenerId, reason: Result<(), io::Error>) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, can do.

}

/// Polls for things that swarm should do.
Expand Down Expand Up @@ -252,4 +252,3 @@ pub enum NotifyHandler {
/// Notify all connection handlers.
All
}

6 changes: 5 additions & 1 deletion swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ where TBehaviour: NetworkBehaviour<ProtocolsHandler = THandler>,
for addr in addresses.iter() {
this.behaviour.inject_expired_listen_addr(addr);
}
this.behaviour.inject_listener_closed(listener_id);
let err = match reason {
Ok(()) => None,
Err(e) => Some(e),
};
this.behaviour.inject_listener_closed(listener_id, err);
}
Poll::Ready(NetworkEvent::ListenerError { listener_id, error }) =>
this.behaviour.inject_listener_error(listener_id, &error),
Expand Down