|
|
|
|
@ -91,6 +91,15 @@ static struct ncd_entry* ncd_registry_find(struct UTUN_INSTANCE* inst, uint64_t
|
|
|
|
|
while (e) { if (e->node_id == node_id && !e->closed && !e->conn->close_requested && e->conn->state != 2) return e; e = e->next; } |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Проверка владения по объекту conn исключает смешение старого и нового транспорта одного пира.
|
|
|
|
|
int node_conn_direct_handle_count(const struct ETCP_CONN* conn) { |
|
|
|
|
if (!conn || !conn->instance) return 0; |
|
|
|
|
for (const struct ncd_entry* entry = conn->instance->ncd_registry; entry; entry = entry->next) |
|
|
|
|
if (entry->conn == conn && !entry->closed) return entry->handle_count; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int ncd_registry_add(struct UTUN_INSTANCE* inst, struct ncd_entry* entry) { |
|
|
|
|
entry->inst = inst; |
|
|
|
|
if (etcp_conn_ref_take(entry->conn) != 0) { DEBUG_ERROR(DEBUG_CATEGORY_NCD, "[ncd] register closing conn"); return -1; } |
|
|
|
|
|