From 1bf71795fcae0a03a6754f22be6f79794f751bca Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Fri, 14 Feb 2025 13:59:51 +0800 Subject: [PATCH] select: fix too small timeout will be counted as 0 avoiding timeouts less than 1ms may lead to busyloop Signed-off-by: zhanghongyu --- fs/vfs/fs_select.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/vfs/fs_select.c b/fs/vfs/fs_select.c index d8393a8cb2c..fde14c2a9fb 100644 --- a/fs/vfs/fs_select.c +++ b/fs/vfs/fs_select.c @@ -204,7 +204,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, { /* Calculate the timeout in milliseconds */ - msec = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; + msec = timeout->tv_sec * 1000 + (timeout->tv_usec + 999) / 1000; } else {