Release borrowed send-hook owners before ETCP link teardown
This commit is contained in:
1 parent
36c096c4e9
commit
83bf76dd41
2 files changed
+6
No files matched your search
@@ -1089,6 +1089,7 @@ struct ETCP_LINK* etcp_link_new(struct ETCP_CONN* etcp, struct ETCP_SOCKET* conn
|
||||
link->link_status = 0;
|
||||
link->send_hook = NULL;
|
||||
link->send_hook_ctx = NULL;
|
||||
link->send_hook_release = NULL;
|
||||
|
||||
// Initialize keepalive timeout from global config
|
||||
if (etcp->instance && etcp->instance->config) {
|
||||
@@ -1238,6 +1239,10 @@ void etcp_link_close(struct ETCP_LINK* link) {
|
||||
link->closing = 1;
|
||||
struct ETCP_CONN *etcp = link->etcp;
|
||||
etcp->callbacks_running++;
|
||||
void (*release_hook)(struct ETCP_LINK*, void*) = link->send_hook_release;
|
||||
void* hook_context = link->send_hook_ctx;
|
||||
link->send_hook = NULL; link->send_hook_ctx = NULL; link->send_hook_release = NULL;
|
||||
if (release_hook) release_hook(link, hook_context);
|
||||
int old_state = link->link_state, old_status = link->link_status;
|
||||
link->link_status = link->recv_keepalive = link->initialized = 0;
|
||||
if (link->rx_timeout_timer) {
|
||||
|
||||
@@ -364,6 +364,7 @@ struct ETCP_LINK {
|
||||
|
||||
etcp_udp_send_fn_t send_hook; // Перехват прямого UDP; NULL = socket_sendto, SOCKS5 имеет приоритет
|
||||
void* send_hook_ctx;
|
||||
void (*send_hook_release)(struct ETCP_LINK*, void*); // Необязательная отвязка ctx при close; три поля очищаются до вызова
|
||||
|
||||
struct sockaddr_storage local_bound_addr; // локальный адрес к которому привязан линк (interface_addr на момент создания)
|
||||
uint8_t is_tcp; // 1 = TCP транспорт (STCP)
|
||||
|
||||
Reference in new issue
Block a user