Close NAT channels after cancelling producers and quiet transient TUN backpressure
This commit is contained in:
1 parent
cfc0051088
commit
41a68b86bc
3 files changed
+15
-1
No files matched your search
@@ -315,6 +315,16 @@ void nat_transport_destroy(struct UTUN_INSTANCE* inst) {
|
||||
struct ll_entry* peer;
|
||||
while ((peer = queue_data_get(tr->peers))) nat_peer_free((struct nat_peer*)peer);
|
||||
queue_free(tr->peers);
|
||||
// После отмены producers закрыть только каналы NAT; остальные сервисы ядра продолжают работать.
|
||||
while (inst->router_conns) {
|
||||
struct ETCP_ROUTER_CONN* route = NULL;
|
||||
for (struct ll_entry* e = inst->router_conns->head; e; e = e->next) {
|
||||
struct ETCP_ROUTER_CONN* candidate = (struct ETCP_ROUTER_CONN*)e;
|
||||
if (candidate->svc_id == ETCP_RT_ID_NAT) { route = candidate; break; }
|
||||
}
|
||||
if (!route) break;
|
||||
etcp_router_conn_close(route);
|
||||
}
|
||||
nat_packet_free(tr->tun_pending);
|
||||
tun_close(tr->nat_tun);
|
||||
eim_nat_destroy_ctx(&inst->nat);
|
||||
|
||||
+3
-1
@@ -255,7 +255,9 @@ ssize_t tun_write(struct tun_if* tun, const uint8_t* buf, size_t len) {
|
||||
} while (n < 0 && errno == EINTR);
|
||||
if (n != (ssize_t)len) {
|
||||
int error = n < 0 ? errno : EIO;
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_TUN, "TUN %s write failed: requested=%zu written=%zd error=%s", tun->ifname, len, n, strerror(error));
|
||||
if (error == EAGAIN || error == EWOULDBLOCK)
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_TUN, "TUN %s write backpressure: requested=%zu", tun->ifname, len);
|
||||
else DEBUG_ERROR(DEBUG_CATEGORY_TUN, "TUN %s write failed: requested=%zu written=%zd error=%s", tun->ifname, len, n, strerror(error));
|
||||
tun->write_errors++;
|
||||
errno = error;
|
||||
return -1;
|
||||
|
||||
Reference in new issue
Block a user