From 041ec6e1f8181342ad6bb91b346abd46fc95ae60 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 3 May 2025 10:28:36 +0100 Subject: [PATCH] Close if drained --- mongoose.c | 1 + src/net_builtin.c | 1 + 2 files changed, 2 insertions(+) diff --git a/mongoose.c b/mongoose.c index a3142326..a1362b62 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5361,6 +5361,7 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) { if (s->twclosure && (!c->is_tls || (c->rtls.len == 0 && mg_tls_pending(c) == 0))) c->is_closing = 1; + if (c->is_draining && c->send.len == 0) c->is_closing = 1; if (c->is_closing) close_conn(c); } (void) ms; diff --git a/src/net_builtin.c b/src/net_builtin.c index ad588072..c486e110 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -1199,6 +1199,7 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) { if (s->twclosure && (!c->is_tls || (c->rtls.len == 0 && mg_tls_pending(c) == 0))) c->is_closing = 1; + if (c->is_draining && c->send.len == 0) c->is_closing = 1; if (c->is_closing) close_conn(c); } (void) ms;