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;