mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
poll: fix 0 timeout
This commit is contained in:
+5
-11
@@ -20,25 +20,18 @@ syscallret syscall_poll(pollfd *fds, size_t nfds, int timeoutms){
|
|||||||
retv.errno = EINVAL;
|
retv.errno = EINVAL;
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// create the internal list
|
// create the internal list
|
||||||
|
|
||||||
pollfd* ilist = alloc(1);
|
pollfd* ilist = alloc(nfds * sizeof(pollfd));
|
||||||
|
|
||||||
if(!ilist){
|
if(!ilist){
|
||||||
retv.errno = ENOMEM;
|
retv.errno = ENOMEM;
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t fd = 0; fd < nfds; ++fd){
|
for(size_t fd = 0; fd < nfds; ++fd){
|
||||||
|
|
||||||
void* tmp = realloc(ilist,(fd+1)*sizeof(pollfd));
|
|
||||||
if(!tmp){
|
|
||||||
retv.errno = ENOMEM;
|
|
||||||
goto ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ilist[fd].fd = fds[fd].fd;
|
ilist[fd].fd = fds[fd].fd;
|
||||||
ilist[fd].events = fds[fd].events;
|
ilist[fd].events = fds[fd].events;
|
||||||
}
|
}
|
||||||
@@ -83,7 +76,8 @@ syscallret syscall_poll(pollfd *fds, size_t nfds, int timeoutms){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO check for signal or timeout
|
// TODO check for signal or timeout
|
||||||
|
|
||||||
|
if(timeoutms == 0) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user