net/tcp: do not start the tcp monitor if unestablished

Change-Id: Iace9ccfc73086db442db04b95bc508dd48827b82
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2021-03-18 23:30:40 +08:00
committed by chao an
parent 08c6d63e9a
commit 2919001e3e
+7 -1
View File
@@ -46,6 +46,7 @@
#include <debug.h>
#include <nuttx/net/net.h>
#include <nuttx/net/tcp.h>
#include "inet/inet.h"
#include "tcp/tcp.h"
@@ -74,6 +75,7 @@
int psock_dup2(FAR struct socket *psock1, FAR struct socket *psock2)
{
FAR struct tcp_conn_s *conn;
int ret = OK;
/* Parts of this operation need to be atomic */
@@ -112,7 +114,11 @@ int psock_dup2(FAR struct socket *psock1, FAR struct socket *psock2)
* the network connection is lost.
*/
if (psock2->s_type == SOCK_STREAM)
conn = (FAR struct tcp_conn_s *)psock2->s_conn;
if (psock2->s_type == SOCK_STREAM && conn &&
(conn->tcpstateflags == TCP_ESTABLISHED ||
conn->tcpstateflags == TCP_SYN_RCVD))
{
ret = tcp_start_monitor(psock2);