fix half_close: send CLOSE from proxy_poll_cb when no pending data, shutdown not close on exit
This commit is contained in:
1 parent
f9d5495993
commit
ca3215ab91
2 files changed
+7
-6
No files matched your search
+2
-1
@@ -232,7 +232,8 @@ void remote_proxy_handle_close(struct UTUN_INSTANCE* inst, uint64_t stream_id) {
|
||||
while (*prev) {
|
||||
struct remote_proxy_conn* rc = *prev;
|
||||
if (rc->stream_id == stream_id) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "remote_proxy: close stream=%016llx", (unsigned long long)stream_id);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "RP CLOSE stream=%016llx", (unsigned long long)stream_id);
|
||||
if (rc->sock != SOCKET_INVALID && rc->connected == 1) shutdown(rc->sock, SHUT_WR);
|
||||
*prev = rc->next; rp_conn_free(rc); return;
|
||||
}
|
||||
prev = &rc->next;
|
||||
|
||||
+5
-5
@@ -263,11 +263,6 @@ static err_t proxy_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t
|
||||
if (p == NULL || err != LERR_OK) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY FIN stream=%016llx tun=1 active=%d", (unsigned long long)(pc->remote_stream_id ? pc->remote_stream_id : 0), pc->active);
|
||||
pc->closing_tun = 1;
|
||||
if (pc->closing_rem) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLOSE stream=%016llx tun=1 rem=1 (recv)", (unsigned long long)pc->remote_stream_id);
|
||||
} else if (pc->transport) {
|
||||
pc->transport->ops->close(pc->transport);
|
||||
}
|
||||
return LERR_OK;
|
||||
}
|
||||
|
||||
@@ -314,6 +309,11 @@ static void proxy_err_cb(void *arg, err_t err) {
|
||||
static err_t proxy_poll_cb(void *arg, struct tcp_pcb *pcb) {
|
||||
struct proxy_conn *pc = (struct proxy_conn *)arg;
|
||||
if (!pc) return LERR_OK;
|
||||
if (pc->closing_tun && !pc->closing_rem && pc->transport && pc->transport_to_uip
|
||||
&& queue_entry_count(pc->transport_to_uip) == 0) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLOSE stream=%016llx tun=1 (no pending)", (unsigned long long)pc->remote_stream_id);
|
||||
pc->transport->ops->close(pc->transport);
|
||||
}
|
||||
if (pc->closing_tun && pc->closing_rem && pc->pcb) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLOSE stream=%016llx tun=1 rem=1", (unsigned long long)pc->remote_stream_id);
|
||||
struct tcp_pcb *save = pc->pcb;
|
||||
|
||||
Reference in new issue
Block a user