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

fix(p2p): handle multiple socket errors #1777

Merged
2 commits merged into from
Aug 4, 2020
Merged

fix(p2p): handle multiple socket errors #1777

2 commits merged into from
Aug 4, 2020

Conversation

sangaman
Copy link
Collaborator

@sangaman sangaman commented Aug 3, 2020

Fixes #1773

This changes the peer socket error handling to use on instead of once when listening for error events to ensure that an unexpected second error event doesn't crash xud after the once handler stops listening. Instead we use on to listen to all error events and then manually remove all listeners from the socket after it's destroyed.

This also adds a callback to handle errors from the socket.write function when sending packets to peers. Previously we would not specify a callback at all, and errors would only get handled by the generic socket.on('error') event handler.

This changes the peer socket error handling to use `on` instead of `once`
when listening for `error` events to ensure that an unexpected second
`error` event doesn't crash xud after the `once` handler stops listening.
Instead we use `on` to listen to all error events and then manually
remove all listeners from the socket after it's destroyed.

Fixes #1773
This adds a callback to handle errors from the `socket.write` function
when sending packets to peers. Previously we would not specify a
callback at all, and errors would only get handled by the generic
`socket.on('error')` event handler.
@sangaman sangaman added bug Something isn't working error handling Handling errors gracefully p2p Peer to peer networking labels Aug 3, 2020
@sangaman sangaman requested review from a user and raladev August 3, 2020 05:42
@sangaman sangaman self-assigned this Aug 3, 2020
@ghost ghost merged commit b219b26 into master Aug 4, 2020
@ghost ghost deleted the p2p/socket-error branch August 4, 2020 11:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working error handling Handling errors gracefully p2p Peer to peer networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhandled socket connection err leads to xud crash
2 participants