tcp_monitor: start_monitor return OK when connect closed by peer
If TCP_FIN is received before the user calls accept, the later accept will report an error, then the previously received data cannot be read. operation flow: tcp_server_listen -> tcp_client_connect -> tcp_client_send -> tcp_client_close -> tcp_server_accept(fix this error) -> tcp_server_recv Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
f7cfcd4e95
commit
646c41dced
|
@ -271,6 +271,18 @@ int tcp_start_monitor(FAR struct socket *psock)
|
|||
|
||||
tcp_shutdown_monitor(conn, TCP_CLOSE);
|
||||
|
||||
/* If the peer close the connection before we call accept,
|
||||
* in order to allow user to read the readahead data,
|
||||
* return OK.
|
||||
*/
|
||||
|
||||
if (conn->tcpstateflags == TCP_CLOSED ||
|
||||
conn->tcpstateflags == TCP_LAST_ACK)
|
||||
{
|
||||
net_unlock();
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* And return -ENOTCONN to indicate the monitor was not started
|
||||
* because the socket was already disconnected.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue