Skip to content

Commit

Permalink
Handle tcp self connection issues (#4599)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdillonharvey authored Oct 10, 2023
1 parent dbb7e3d commit 9d31965
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct endpoint_uri_pair_t
return local_type == endpoint_type_bind ? local : remote;
}

const bool clash () const { return local == remote; }

std::string local, remote;
endpoint_type_t local_type;
};
Expand Down
10 changes: 8 additions & 2 deletions src/stream_engine_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,14 @@ bool zmq::stream_engine_base_t::in_event_internal ()
// or the session has rejected the message.
if (rc == -1) {
if (errno != EAGAIN) {
error (protocol_error);
return false;
// In cases where the src/dst have the same IP and the dst uses an ephemeral port, reconnection
// eventually results in the src and dest IP and port clashing (google tcp self connection)
// While this is a protocol_error (you have the single zmq socket handshaking with itself)
// we do not want to to stop reconnection from happening
if (!_endpoint_uri_pair.clash ()) {
error (protocol_error);
return false;
}
}
_input_stopped = true;
reset_pollin (_handle);
Expand Down

0 comments on commit 9d31965

Please sign in to comment.