Cancel pending transit queues when destroying the router
This commit is contained in:
1 parent
268b7db8de
commit
6cf08cafe0
2 files changed
+51
-1
No files matched your search
@@ -239,18 +239,22 @@ static void transit_queue_drain_cb(struct ll_queue* q, void* arg) {
|
||||
// Удалить все транзитные очереди соединения (вызывается при закрытии ETCP_CONN).
|
||||
void etcp_router_transit_queues_destroy(struct ETCP_CONN* conn) {
|
||||
if (!conn || !conn->transit_queues) return;
|
||||
int pairs = 0, dropped = 0;
|
||||
struct ll_entry* entry;
|
||||
while ((entry = queue_data_get(conn->transit_queues)) != NULL) {
|
||||
struct TRANSIT_QUEUE* tq = (struct TRANSIT_QUEUE*)entry;
|
||||
if (tq->route_timer) uasync_cancel_timeout(conn->instance->ua, tq->route_timer);
|
||||
if (conn->send_input_q) queue_waiter_cancel(conn->send_input_q, &tq->waiter);
|
||||
struct ll_entry* e;
|
||||
while ((e = queue_data_get(tq->q)) != NULL) free_entry(e);
|
||||
while ((e = queue_data_get(tq->q)) != NULL) { free_entry(e); dropped++; }
|
||||
queue_free(tq->q);
|
||||
queue_entry_free(&tq->ll);
|
||||
pairs++;
|
||||
}
|
||||
queue_free(conn->transit_queues);
|
||||
conn->transit_queues = NULL;
|
||||
if (pairs) DEBUG_DEBUG(DEBUG_CATEGORY_ETCPROUTE, "transit queues released: peer=%016llx pairs=%d discarded=%d",
|
||||
(unsigned long long)conn->peer_node_id, pairs, dropped);
|
||||
}
|
||||
|
||||
// Сбросить recv_conn у всех ROUTER_CONN, ссылающихся на уничтожаемый ETCP_CONN.
|
||||
@@ -1438,6 +1442,10 @@ void etcp_router_destroy(struct UTUN_INSTANCE* inst) {
|
||||
queue_free(inst->router_conns);
|
||||
inst->router_conns = NULL;
|
||||
}
|
||||
for (struct ll_entry* entry = inst->connections ? inst->connections->head : NULL; entry; entry = entry->next) {
|
||||
struct ETCP_CONN* conn = ((struct conn_queue_entry*)entry->data)->conn;
|
||||
if (conn) etcp_router_transit_queues_destroy(conn);
|
||||
}
|
||||
memset(&inst->router_bindings, 0, sizeof(inst->router_bindings));
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCPROUTE, "etcp_router destroyed");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user