net/tcp: remove conn check since which can not be NULL

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-02-02 11:41:58 +08:00
committed by Xiang Xiao
parent 4c8d244fae
commit 247b050e5f
2 changed files with 28 additions and 29 deletions
+3 -1
View File
@@ -159,7 +159,7 @@ static uint16_t psock_connect_eventhandler(FAR struct net_driver_s *dev,
FAR void *pvpriv, uint16_t flags) FAR void *pvpriv, uint16_t flags)
{ {
struct tcp_connect_s *pstate = pvpriv; struct tcp_connect_s *pstate = pvpriv;
FAR struct tcp_conn_s *conn = pstate->tc_conn; FAR struct tcp_conn_s *conn;
ninfo("flags: %04x\n", flags); ninfo("flags: %04x\n", flags);
@@ -167,6 +167,8 @@ static uint16_t psock_connect_eventhandler(FAR struct net_driver_s *dev,
if (pstate) if (pstate)
{ {
conn = pstate->tc_conn;
/* The following errors should be detected here (someday) /* The following errors should be detected here (someday)
* *
* ECONNREFUSED * ECONNREFUSED
+25 -28
View File
@@ -273,47 +273,44 @@ static inline void psock_lost_connection(FAR struct tcp_conn_s *conn,
conn->sndcb->event = NULL; conn->sndcb->event = NULL;
} }
if (conn != NULL) /* Free all queued write buffers */
for (entry = sq_peek(&conn->unacked_q); entry; entry = next)
{ {
/* Free all queued write buffers */ next = sq_next(entry);
tcp_wrbuffer_release((FAR struct tcp_wrbuffer_s *)entry);
}
for (entry = sq_peek(&conn->unacked_q); entry; entry = next) for (entry = sq_peek(&conn->write_q); entry; entry = next)
{ {
next = sq_next(entry); next = sq_next(entry);
tcp_wrbuffer_release((FAR struct tcp_wrbuffer_s *)entry); tcp_wrbuffer_release((FAR struct tcp_wrbuffer_s *)entry);
} }
for (entry = sq_peek(&conn->write_q); entry; entry = next)
{
next = sq_next(entry);
tcp_wrbuffer_release((FAR struct tcp_wrbuffer_s *)entry);
}
#if CONFIG_NET_SEND_BUFSIZE > 0 #if CONFIG_NET_SEND_BUFSIZE > 0
/* Notify the send buffer available */ /* Notify the send buffer available */
tcp_sendbuffer_notify(conn); tcp_sendbuffer_notify(conn);
#endif /* CONFIG_NET_SEND_BUFSIZE */ #endif /* CONFIG_NET_SEND_BUFSIZE */
/* Reset write buffering variables */ /* Reset write buffering variables */
sq_init(&conn->unacked_q); sq_init(&conn->unacked_q);
sq_init(&conn->write_q); sq_init(&conn->write_q);
/* Notify any waiters if the write buffers have been drained. */ /* Notify any waiters if the write buffers have been drained. */
psock_writebuffer_notify(conn); psock_writebuffer_notify(conn);
conn->sent = 0; conn->sent = 0;
conn->sndseq_max = 0; conn->sndseq_max = 0;
/* Force abort the connection. */ /* Force abort the connection. */
if (abort) if (abort)
{ {
conn->tx_unacked = 0; conn->tx_unacked = 0;
conn->tcpstateflags = TCP_CLOSED; conn->tcpstateflags = TCP_CLOSED;
}
} }
} }