You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/01/17 05:48:56 UTC

[GitHub] [incubator-nuttx] anchao commented on a change in pull request #5242: net/tcp/sendfile: TCP retransmission could not start because of incorrect snd_ackcb callback handling

anchao commented on a change in pull request #5242:
URL: https://github.com/apache/incubator-nuttx/pull/5242#discussion_r785651366



##########
File path: net/tcp/tcp_sendfile.c
##########
@@ -87,17 +86,63 @@ struct sendfile_s
   uint32_t           snd_acked;            /* The number of bytes acked */
 };
 
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline void sendfile_txnotify(FAR struct socket *psock,
+                                     FAR struct tcp_conn_s *conn);
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
-static uint16_t ack_eventhandler(FAR struct net_driver_s *dev,
-                                 FAR void *pvconn,
-                                 FAR void *pvpriv, uint16_t flags)
+/****************************************************************************
+ * Name: sendfile_eventhandler
+ *
+ * Description:
+ *   This function is called to perform the actual send operation when
+ *   polled by the lower, device interfacing layer.
+ *
+ * Input Parameters:
+ *   dev      The structure of the network driver that caused the event
+ *   conn     The connection structure associated with the socket
+ *   flags    Set of events describing why the callback was invoked
+ *
+ * Returned Value:
+ *   None
+ *
+ * Assumptions:
+ *   The network is locked
+ *
+ ****************************************************************************/
+
+static uint16_t sendfile_eventhandler(FAR struct net_driver_s *dev,
+                                      FAR void *pvconn, FAR void *pvpriv,
+                                      uint16_t flags)
 {
+  FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn;
   FAR struct sendfile_s *pstate = (FAR struct sendfile_s *)pvpriv;
+  FAR struct socket *psock = pstate->snd_sock;
+  int ret;
+
+  /* The TCP socket is connected and, hence, should be bound to a device.
+   * Make sure that the polling device is the own that we are bound to.
+   */
+
+  DEBUGASSERT(conn);

Review comment:
       move after  check TCP_DISCONN_EVENTS

##########
File path: net/tcp/tcp_sendfile.c
##########
@@ -148,14 +206,15 @@ static uint16_t ack_eventhandler(FAR struct net_driver_s *dev,
        */
 
       pstate->snd_sent = pstate->snd_acked;
+#ifndef CONFIG_NET_TCP_WRITE_BUFFERS
+      conn->rexmit_seq = pstate->snd_sent + pstate->snd_isn;
+#endif
     }
 
   /* Check for a loss of connection */
 
   else if ((flags & TCP_DISCONN_EVENTS) != 0)

Review comment:
       check the disconnect event at first segment, the conn instance could be NULL:
   https://github.com/apache/incubator-nuttx/blob/master/net/netdev/netdev_carrier.c#L97

##########
File path: net/tcp/tcp_sendfile.c
##########
@@ -87,17 +86,63 @@ struct sendfile_s
   uint32_t           snd_acked;            /* The number of bytes acked */
 };
 
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline void sendfile_txnotify(FAR struct socket *psock,

Review comment:
       move the sendfile_txnotify() implement before caller




-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org