diff --git a/ChangeLog b/ChangeLog index 77778f1eaa..3bcb07ffca 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11575,6 +11575,6 @@ completes and NBUSYBKS > 0, the NBUSYBK is interrupt is enabled and the operations are deferred until NBUSYBKS is truly zero (2016-03-17). * net/tcp/tcp_timer.c: Fix some logic when there are multiple network - interfaces. In this case, TCP timeout events can really only bei + interfaces. In this case, TCP timeout events can really only being processed when the poll from the correct device is received (2016-03-20). diff --git a/net/tcp/tcp_devpoll.c b/net/tcp/tcp_devpoll.c index e4fadc6be6..daa85e062a 100644 --- a/net/tcp/tcp_devpoll.c +++ b/net/tcp/tcp_devpoll.c @@ -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); + } } }