mirror of
https://github.com/apache/nuttx.git
synced 2025-12-19 19:08:23 +08:00
TCP poll: TCP poll events can really only being processed when the poll from the correct device is received.
This commit is contained in:
@@ -81,37 +81,43 @@ void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
||||
{
|
||||
uint16_t result;
|
||||
|
||||
/* Verify that the connection is established */
|
||||
/* Discard any currently buffered data */
|
||||
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
/* Verify that the connection is established. */
|
||||
|
||||
if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||
{
|
||||
/* Set up for the callback. We can't know in advance if the application
|
||||
* is going to send a IPv4 or an IPv6 packet, so this setup may not
|
||||
* actually be used.
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
/* The TCP connection is established and, hence, should be bound
|
||||
* to a device. Make sure that the polling device is the one that
|
||||
* we are bound to.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NET_IPv4)
|
||||
tcp_ipv4_select(dev);
|
||||
#else /* if defined(CONFIG_NET_IPv6) */
|
||||
tcp_ipv6_select(dev);
|
||||
DEBUGASSERT(conn->dev != NULL);
|
||||
if (dev != conn->dev)
|
||||
#endif
|
||||
{
|
||||
/* Set up for the callback. We can't know in advance if the
|
||||
* application is going to send a IPv4 or an IPv6 packet, so this
|
||||
* setup may not actually be used.
|
||||
*/
|
||||
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
#if defined(CONFIG_NET_IPv4)
|
||||
tcp_ipv4_select(dev);
|
||||
#else /* if defined(CONFIG_NET_IPv6) */
|
||||
tcp_ipv6_select(dev);
|
||||
#endif
|
||||
/* Perform the callback */
|
||||
|
||||
/* Perform the callback */
|
||||
result = tcp_callback(dev, conn, TCP_POLL);
|
||||
|
||||
result = tcp_callback(dev, conn, TCP_POLL);
|
||||
/* Handle the callback response */
|
||||
|
||||
/* Handle the callback response */
|
||||
|
||||
tcp_appsend(dev, conn, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nothing to do for this connection */
|
||||
|
||||
dev->d_len = 0;
|
||||
tcp_appsend(dev, conn, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user