fix ETCP: dgram leak on inflight pool exhaustion, cancel dangling timers on link close/new

This commit is contained in:
Evgeny committed 2026-05-14 03:35:26 +03:00
1 parent 4d5afe5ae9
commit 194c8398c1
2 files changed
+13 -4

No files matched your search

+2 -1
View File
@@ -678,7 +678,8 @@ static void input_queue_cb(struct ll_queue* q, void* arg) {
struct INFLIGHT_PACKET* p = (struct INFLIGHT_PACKET*)queue_entry_new_from_pool(etcp->inflight_pool);
if (!p) {
DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[%s] cannot allocate INFLIGHT_PACKET (pool=%p etcp=%p)", etcp->log_name, etcp->inflight_pool, etcp);
queue_entry_free((struct ll_entry*)in_pkt); // Free the ETCP_FRAGMENT
queue_dgram_free(&in_pkt->ll);
queue_entry_free((struct ll_entry*)in_pkt);
queue_resume_callback(q);
return;
}
+11 -3
View File
@@ -847,9 +847,8 @@ struct ETCP_LINK* etcp_link_new(struct ETCP_CONN* etcp, struct ETCP_SOCKET* conn
// insert_link(conn, link);
if (insert_link(conn, link) < 0) {
// откатываем то, что успели
// (пока список ещё не добавлен — просто free)
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "Can not insert link to socket");
uasync_cancel_timeout(link->etcp->instance->ua, link->stats_timer);
u_free(link);
return NULL;
}
@@ -876,11 +875,20 @@ struct ETCP_LINK* etcp_link_new(struct ETCP_CONN* etcp, struct ETCP_SOCKET* conn
void etcp_link_close(struct ETCP_LINK* link) {
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "");
if (!link) return;
if (link->burst_resp_timer) {
uasync_cancel_timeout(link->etcp->instance->ua, link->burst_resp_timer);
link->burst_resp_timer = NULL;
}
if (!link->conn) {
// только удаляем из списка и free
struct ETCP_LINK **pp = &link->etcp->links;
while (*pp && *pp != link) pp = &(*pp)->next;
if (*pp) *pp = link->next;
if (link->stats_timer) uasync_cancel_timeout(link->etcp->instance->ua, link->stats_timer);
if (link->init_timer) uasync_cancel_timeout(link->etcp->instance->ua, link->init_timer);
if (link->shaper_timer) uasync_cancel_timeout(link->etcp->instance->ua, link->shaper_timer);
if (link->keepalive_timer) uasync_cancel_timeout(link->etcp->instance->ua, link->keepalive_timer);
u_free(link);
return;
}