fs/select : Prevent assert when select called after close
@@ -273,10 +273,18 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
FAR struct inode *inode;
int ret = -ENOSYS;
- DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
+ DEBUGASSERT(filep != NULL);
inode = filep->f_inode;
- if (inode != NULL) {
+ /* If inode is null, notify error result */
+ if (inode == NULL) {
+ /* Error case, it is lost connection, There can be readable data exist */
+ fds->revents |= (POLLERR | POLLHUP);
+ fds->revents &= ~POLLOUT;
+ sem_post(fds->sem);
+ return OK;
+ }
+
/* Is a driver registered? Does it support the poll method?
* If not, return -ENOSYS
*/
@@ -303,7 +311,6 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
ret = OK;
}
- }
return ret;
}
