Merge pull request #3130 from cesanta/longpost

fix broken TCP closure
This commit is contained in:
Sergey Lyubka 2025-05-13 22:26:15 +01:00 committed by GitHub
commit a3b63f3b0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -4339,6 +4339,7 @@ static void settmout(struct mg_connection *c, uint8_t type) {
: type == MIP_TTYPE_SYN ? MIP_TCP_SYN_MS
: type == MIP_TTYPE_FIN ? MIP_TCP_FIN_MS
: MIP_TCP_KEEPALIVE_MS;
if (s->ttype == MIP_TTYPE_FIN) return; // skip if 3-way closing
s->timer = ifp->now + n;
s->ttype = type;
MG_VERBOSE(("%lu %d -> %llx", c->id, type, s->timer));
@ -5386,7 +5387,6 @@ 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;

View File

@ -177,6 +177,7 @@ static void settmout(struct mg_connection *c, uint8_t type) {
: type == MIP_TTYPE_SYN ? MIP_TCP_SYN_MS
: type == MIP_TTYPE_FIN ? MIP_TCP_FIN_MS
: MIP_TCP_KEEPALIVE_MS;
if (s->ttype == MIP_TTYPE_FIN) return; // skip if 3-way closing
s->timer = ifp->now + n;
s->ttype = type;
MG_VERBOSE(("%lu %d -> %llx", c->id, type, s->timer));
@ -1224,7 +1225,6 @@ 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;