net/tcp: discard connect reference before free
connect reference should be set to 0 before free Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
bd713d6431
commit
b88a1fd7fd
@ -58,6 +58,10 @@ static void tcp_close_work(FAR void *param)
|
||||
/* Stop the network monitor for all sockets */
|
||||
|
||||
tcp_stop_monitor(conn, TCP_CLOSE);
|
||||
|
||||
/* Discard our reference to the connection */
|
||||
|
||||
conn->crefs = 0;
|
||||
tcp_free(conn);
|
||||
|
||||
net_unlock();
|
||||
@ -356,7 +360,6 @@ int tcp_close(FAR struct socket *psock)
|
||||
/* Perform the disconnection now */
|
||||
|
||||
tcp_unlisten(conn); /* No longer accepting connections */
|
||||
conn->crefs = 0; /* Discard our reference to the connection */
|
||||
|
||||
/* Break any current connections and close the socket */
|
||||
|
||||
|
@ -696,6 +696,7 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
|
||||
* waiting for it.
|
||||
*/
|
||||
|
||||
conn->crefs = 0;
|
||||
tcp_free(conn);
|
||||
|
||||
/* Now there is guaranteed to be one free connection. Get it! */
|
||||
|
Loading…
Reference in New Issue
Block a user