Expose actual NCD handle ownership for an ETCP transport
This commit is contained in:
1 parent
6704a18897
commit
0d7f7630b0
2 files changed
+12
No files matched your search
@@ -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; }
|
||||
|
||||
@@ -39,6 +39,9 @@ struct ETCP_SOCKET;
|
||||
/* Привязать CLOSE/KEEP_ALIVE при запуске ядра, в том числе без исходящих handles. */
|
||||
int node_conn_direct_init(struct UTUN_INSTANCE* inst);
|
||||
|
||||
/* Число локальных владельцев конкретного транспорта; внешние ETCP refs сюда не входят. */
|
||||
int node_conn_direct_handle_count(const struct ETCP_CONN* conn);
|
||||
|
||||
/* ─── Return codes ─── */
|
||||
#define NCD_NEW 0 /* создано новое соединение */
|
||||
#define NCD_REUSED 1 /* переиспользовано существующее */
|
||||
|
||||
Reference in new issue
Block a user