|
|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|
|