|
|
|
|
@ -661,7 +661,23 @@ void etcp_conn_set_peer_node_id(struct ETCP_CONN* conn, uint64_t peer_node_id) {
|
|
|
|
|
|
|
|
|
|
if (conn->peer_node_id == peer_node_id) return; |
|
|
|
|
|
|
|
|
|
if (conn->state == 1 && conn->peer_node_id != 0) { |
|
|
|
|
if (conn->state == 0 && conn->peer_node_id == 0 && peer_node_id != 0) { |
|
|
|
|
/* первый раз ставим реальный peer_id: переиндексировать из key=0 в key=peer_node_id */ |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] peer_node_id 0 -> 0x%llx, reindexing pending conn", |
|
|
|
|
conn->log_name, (unsigned long long)peer_node_id); |
|
|
|
|
if (conn->conn_queue && conn->conn_queue_entry) { |
|
|
|
|
queue_remove_data(conn->conn_queue, conn->conn_queue_entry); |
|
|
|
|
queue_entry_free(conn->conn_queue_entry); |
|
|
|
|
} |
|
|
|
|
struct ll_entry* qe = queue_entry_new(sizeof(struct conn_queue_entry)); |
|
|
|
|
if (!qe) { DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] reindex alloc failed", conn->log_name); return; } |
|
|
|
|
struct conn_queue_entry* ce = (struct conn_queue_entry*)qe->data; |
|
|
|
|
ce->peer_node_id = peer_node_id; |
|
|
|
|
ce->conn = conn; |
|
|
|
|
conn->conn_queue_entry = qe; |
|
|
|
|
conn->conn_queue = conn->instance->connections; |
|
|
|
|
queue_data_put_with_index(conn->instance->connections, qe); |
|
|
|
|
} else if (conn->state == 1 && conn->peer_node_id != 0) { |
|
|
|
|
// Already in indexed queue with old ID — reindex
|
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] peer_node_id changed 0x%llx -> 0x%llx, reindexing", |
|
|
|
|
conn->log_name, (unsigned long long)conn->peer_node_id, (unsigned long long)peer_node_id); |
|
|
|
|
|