casaroli commented on code in PR #21418:
URL: https://github.com/apache/nuttx/pull/21418#discussion_r4479387497


##########
net/local/local_netpoll.c:
##########
@@ -310,7 +329,14 @@ int local_pollteardown(FAR struct socket *psock, FAR 
struct pollfd_s *fds)
 
   if (conn->lc_proto == SOCK_DGRAM)
     {
-      return -ENOSYS;
+      /* Only a bound socket was registered with file_poll(). */
+
+      if ((fds->events & POLLIN) != 0 && conn->lc_infile.f_inode != NULL)
+        {
+          return file_poll(&conn->lc_infile, fds, false);

Review Comment:
   bind() while another thread is in poll() on the socket hangs the kernel with 
CONFIG_DEBUG_FEATURES off. local_pollsetup() saw no lc_infile and did not 
register with the FIFO, so fds->priv is NULL. local_pollteardown() now sees 
lc_infile open and calls file_poll(false), and pipecommon_poll() writes through 
the NULL slot. The same happens when a socket joins an epoll set unbound, is 
bound, and leaves the set. qemu-armv8a:nsh and :knsh. With 
CONFIG_DEBUG_FEATURES on it returns -EIO instead.
   
   Fix: call file_poll() in local_pollteardown() only when fds->priv != NULL.



-- 
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]

Reply via email to