This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit db7303bbbf36d2cfa56d38e02192eecc86f7a807 Author: wangjianyu3 <[email protected]> AuthorDate: Fri Nov 13 15:38:38 2026 +0800 system/nxinit: retry pollers with no fd and handle POLLHUP/POLLERR Cap the ppoll timeout at 100ms while any poller has a negative fd so its handler keeps being called when init is idle, and also call the handler when its fd reports POLLHUP or POLLERR. Assisted-by: OpenCode:mimo-v2.6-pro Signed-off-by: wangjianyu3 <[email protected]> --- system/nxinit/init.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/system/nxinit/init.c b/system/nxinit/init.c index 7d10e4e03..632190cec 100644 --- a/system/nxinit/init.c +++ b/system/nxinit/init.c @@ -55,6 +55,8 @@ : ((ts)->tv_sec = (ms) / 1000, \ (ts)->tv_nsec = ((ms) % 1000) * 1000000, (ts))) +#define INIT_POLLER_RETRY_MS 100 + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -306,6 +308,15 @@ int main(int argc, FAR char *argv[]) struct timespec timeout; int t = MIN(t1, t2); + for (i = 0; t > INIT_POLLER_RETRY_MS && i < nitems(poller); i++) + { + if (poller[i].pfd->fd < 0) + { + t = INIT_POLLER_RETRY_MS; + break; + } + } + r = ppoll(pfds, nitems(pfds), MS2TIMESPEC(&timeout, t), &mask); if (r < 0 && errno != EINTR) { @@ -316,7 +327,8 @@ int main(int argc, FAR char *argv[]) for (i = 0; i < nitems(poller); i++) { if (poller[i].pfd->fd < 0 || - (poller[i].pfd->revents & poller[i].pfd->events)) + (poller[i].pfd->revents & + (poller[i].pfd->events | POLLHUP | POLLERR))) { poller[i].handle(&poller[i]); }
