xiaoxiang781216 commented on code in PR #8129:
URL: https://github.com/apache/nuttx/pull/8129#discussion_r1072273342
##########
net/udp/udp_close.c:
##########
@@ -85,7 +85,8 @@ int udp_close(FAR struct socket *psock)
if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
{
- timeout = _SO_TIMEOUT(conn->sconn.s_linger);
+ timeout = (conn->sconn.s_linger == 0) ? 0 :
Review Comment:
merge to previous patch
##########
net/tcp/tcp_timer.c:
##########
@@ -702,6 +748,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct
tcp_conn_s *conn)
dev->d_len = 0;
done:
+
Review Comment:
revert
##########
net/tcp/tcp_close.c:
##########
@@ -318,6 +289,35 @@ static inline int tcp_close_disconnect(FAR struct socket
*psock)
conn->clscb->event = tcp_close_eventhandler;
conn->clscb->priv = conn; /* reference for event handler to free cb */
+#ifdef CONFIG_NET_SOLINGER
+ /* SO_LINGER
+ * Lingers on a close() if data is present. This option controls the
+ * action taken when unsent messages queue on a socket and close() is
+ * performed. If SO_LINGER is set, the system shall block the calling
+ * thread during close() until it can transmit the data or until the
+ * time expires. If SO_LINGER is not specified, and close() is
+ * issued, the system handles the call in a way that allows the
+ * calling thread to continue as quickly as possible. This option
+ * takes a linger structure, as defined in the <sys/socket.h> header,
+ * to specify the state of the option and linger interval.
+ */
+
+ if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
+ {
+ sclock_t expire = DSEC2TICK(conn->sconn.s_linger);
+
+ conn->ltimeout = clock_systime_ticks() + expire;
Review Comment:
tcp_update_timer
##########
net/tcp/tcp_timer.c:
##########
@@ -352,6 +372,32 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct
tcp_conn_s *conn)
return;
}
+#ifdef CONFIG_NET_SOLINGER
+ /* Send reset immediately if linger timeout */
+
+ if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER) &&
Review Comment:
remove the check
##########
net/tcp/tcp_timer.c:
##########
@@ -180,7 +180,27 @@ static void tcp_update_timer(FAR struct tcp_conn_s *conn)
if (timeout > 0)
{
- if (TICK2HSEC(work_timeleft(&conn->work)) != timeout)
+#ifdef CONFIG_NET_SOLINGER
+ /* Re-update tcp timeout */
+
+ if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER) &&
Review Comment:
remove
##########
net/tcp/tcp_timer.c:
##########
@@ -352,6 +372,32 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct
tcp_conn_s *conn)
return;
}
+#ifdef CONFIG_NET_SOLINGER
+ /* Send reset immediately if linger timeout */
+
+ if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER) &&
+ conn->ltimeout != 0 &&
+ ((int)(conn->ltimeout - clock_systime_ticks()) <= 0))
Review Comment:
int->sclock_t
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]