mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
fs/vfs/fs_select.c: Make select be more consistent with Linux man page: 'The timeout
... Some code calls select() with all three sets empty, nfds zero, and a non-NULL timeout as a fairly portable way to sleep with subsecond precision.'
This commit is contained in:
+10
-11
@@ -103,7 +103,7 @@
|
|||||||
int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
||||||
FAR fd_set *exceptfds, FAR struct timeval *timeout)
|
FAR fd_set *exceptfds, FAR struct timeval *timeout)
|
||||||
{
|
{
|
||||||
struct pollfd *pollset;
|
struct pollfd *pollset = NULL;
|
||||||
int errcode = OK;
|
int errcode = OK;
|
||||||
int fd;
|
int fd;
|
||||||
int npfds;
|
int npfds;
|
||||||
@@ -133,19 +133,18 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npfds <= 0)
|
|
||||||
{
|
|
||||||
errcode = EINVAL;
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate the descriptor list for poll() */
|
/* Allocate the descriptor list for poll() */
|
||||||
|
|
||||||
pollset = (struct pollfd *)kmm_zalloc(npfds * sizeof(struct pollfd));
|
if (npfds > 0)
|
||||||
if (!pollset)
|
|
||||||
{
|
{
|
||||||
errcode = ENOMEM;
|
pollset = (FAR struct pollfd *)
|
||||||
goto errout;
|
kmm_zalloc(npfds * sizeof(struct pollfd));
|
||||||
|
|
||||||
|
if (pollset == NULL)
|
||||||
|
{
|
||||||
|
errcode = ENOMEM;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the descriptor list for poll() */
|
/* Initialize the descriptor list for poll() */
|
||||||
|
|||||||
Reference in New Issue
Block a user