net/tcp: Stop monitor in `tcp_free`

We may just free some TCP connections before monitor stopped, e.g.
sacrificie a TCP conn in `tcp_alloc` will just call `tcp_free` and reuse
the connection.  But we noticed that the TCP monitor is not released in
`tcp_free` because it is mounted on `conn->connevents` instead of
`conn->sconn.list` while `tcp_free` only release the latter.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2023-09-13 21:29:13 +08:00 committed by Xiang Xiao
parent 670c245ff2
commit 33c3abb706
1 changed files with 4 additions and 0 deletions

View File

@ -920,6 +920,10 @@ void tcp_free(FAR struct tcp_conn_s *conn)
tcp_stop_timer(conn);
/* Make sure monitor is stopped. */
tcp_stop_monitor(conn, TCP_CLOSE);
/* Free remaining callbacks, actually there should be only the send
* callback for CONFIG_NET_TCP_WRITE_BUFFERS is left.
*/