This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0c9b1f975e6d4b0311befa298f78ac143c251a0f
Author: zhangyuan29 <[email protected]>
AuthorDate: Thu Sep 10 17:53:45 2026 +0800

    drivers/serial/netdev_console.c: Fix RX stranding in socket poll callback.
    
    The psock_poll callback fires in the UDP RX path before the
    datagram is buffered to the socket read-ahead, so a synchronous
    psock_recv() reads nothing and strands the datagram until the
    next one re-triggers the callback (response to N appears at N+1).
    
    Wake the reader instead of pulling inline: call uart_datareceived()
    so the serial read path pulls the datagram on demand, after the RX
    path has committed it to the read-ahead. Fixes the regression from
    "use socket poll instead of timed polling" with no work queue.
    
    Assisted-by: Claude
    Signed-off-by: zhangyuan29 <[email protected]>
---
 drivers/serial/netdev_console.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/netdev_console.c b/drivers/serial/netdev_console.c
index 2e43973a566..e740b2945a1 100644
--- a/drivers/serial/netdev_console.c
+++ b/drivers/serial/netdev_console.c
@@ -511,7 +511,7 @@ static bool netdev_console_txempty(FAR struct uart_dev_s 
*dev)
  *
  * Description:
  *   Socket poll callback.  Invoked by the network stack when the console
- *   socket becomes readable, so that received data is pulled on demand
+ *   socket becomes readable, so that the blocked reader is woken on demand
  *   rather than by periodically polling from a work queue.
  *
  ****************************************************************************/
@@ -525,7 +525,17 @@ static void netdev_console_poll(FAR struct pollfd_s *fds)
       fds->revents &= ~POLLIN;
       if (priv->rxint)
         {
-          uart_dmarxfree(&priv->dev);
+          /* Do not pull here.  This callback runs inside the network RX
+           * path before the datagram is buffered to the socket read-ahead
+           * (the UDP layer dispatches poll notifications in the step that
+           * precedes read-ahead buffering), so a synchronous psock_recv()
+           * would read nothing and the datagram would stay stranded until
+           * the next one arrives.  Wake the reader instead; the serial
+           * read path pulls on demand in the reader thread, after the RX
+           * path has committed the data to the read-ahead buffer.
+           */
+
+          uart_datareceived(&priv->dev);
         }
     }
 }

Reply via email to