Skip to content

Commit

Permalink
Fix peer dropping (#2780)
Browse files Browse the repository at this point in the history
It turns out that we drop connection if we fail to process a message
because of chain/store/internal error, eg we have a header already, so
we refuse it and drop the peer.
This pr doesn't forward this error to the peer error channel so the
connection will not be dropped.
  • Loading branch information
hashmap authored Apr 26, 2019
1 parent 81a6af9 commit 304ae44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions p2p/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ macro_rules! try_break {
match $inner {
Ok(v) => Some(v),
Err(Error::Connection(ref e)) if e.kind() == io::ErrorKind::WouldBlock => None,
Err(Error::Store(_))
| Err(Error::Chain(_))
| Err(Error::Internal)
| Err(Error::NoDandelionRelay) => None,
Err(e) => {
let _ = $chan.send(e);
break;
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro_rules! connection {
($holder:expr) => {
match $holder.connection.as_ref() {
Some(conn) => conn.lock(),
None => return Err(Error::Internal),
None => return Err(Error::ConnectionClose),
}
};
}
Expand Down

0 comments on commit 304ae44

Please sign in to comment.