tcp_in: Flag the pcb as closing if TCP_EVENT_CLOSED refused

If the packet contained FIN flag, we post a TCP_EVENT_CLOSE with null pbuf,
which could get lost if the underlying platform implementation of sys_mbox_(try)post()
returns ERR_MEM (i.e. won't fit into the recv mailbox).
Loosing this event causes trouble since the FIN initiator gets ACK'ed and
assumes the connection has closed, but the TCP state machine is stuck in its active state.
Fixed by flagging the pcb as closing if the ERR_MEM returned.

Picked from espressif/esp-lwip@d050c331
Patch posted https://savannah.nongnu.org/patch/?10013
Ref IDF-4847
This commit is contained in:
David Cermak
2020-12-29 21:35:25 +01:00
parent 1343f47b0f
commit 223101f1ed
+2
View File
@@ -541,6 +541,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
TCP_EVENT_CLOSED(pcb, err);
if (err == ERR_ABRT) {
goto aborted;
} else if (err == ERR_MEM) {
tcp_set_flags(pcb, TF_CLOSEPEND);
}
}
}