Handle tcp self connection issues (#4599)

This commit is contained in:
James Harvey 2023-10-10 14:46:48 +01:00 committed by GitHub
parent dbb7e3dc01
commit 9d31965548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -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;
};

View File

@ -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);