etcp_connections: reuse existing outbound link for incoming INIT by addr
When two peers send INIT simultaneously, the first link occupies the socket. Incoming INIT arriving after finds the existing outbound link by (ip,port) instead of failing with 'Can not insert link to socket'.
This commit is contained in:
1 parent
0adf7d07ef
commit
fc6a873b5c
1 file changed
+9
@@ -1695,6 +1695,15 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
// Check if link already exists (for CHANNEL_INIT recovery)
|
||||
|
||||
struct ETCP_LINK* existing_link = etcp_link_find_by_remote_id(conn, req->link_id);
|
||||
if (!existing_link) {
|
||||
existing_link = etcp_link_find_by_addr(e_sock, &addr);
|
||||
if (existing_link && existing_link->etcp == conn) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] found existing outbound link by addr for incoming INIT, reusing link=%p",
|
||||
conn->log_name, existing_link);
|
||||
} else {
|
||||
existing_link = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t send_reset = 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user