Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 229863002: [NaCl SDK] nacl_io: Fix select() implementation so it doesn't assume entire fs_sets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/event_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index 680eaac0978acc656fa2955fde7449b376670386..0cd8c10f491d0798b1dc9352612778596d4d0a46 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -1029,28 +1029,24 @@ int KernelProxy::sigaction(int signum, const struct sigaction* action,
int KernelProxy::select(int nfds, fd_set* readfds, fd_set* writefds,
fd_set* exceptfds, struct timeval* timeout) {
- fd_set ignore;
std::vector<pollfd> pollfds;
- // Simplify logic, by using an IGNORE set for any undefined set
- FD_ZERO(&ignore);
- if (NULL == readfds)
- readfds = &ignore;
- if (NULL == writefds)
- writefds = &ignore;
- if (NULL == exceptfds)
- exceptfds = &ignore;
-
for (int fd = 0; fd < nfds; fd++) {
int events = 0;
- if (FD_ISSET(fd, readfds))
+ if (readfds && FD_ISSET(fd, readfds)) {
events |= POLLIN;
+ FD_CLR(fd, readfds);
+ }
- if (FD_ISSET(fd, writefds))
+ if (writefds && FD_ISSET(fd, writefds)) {
events |= POLLOUT;
+ FD_CLR(fd, writefds);
+ }
- if (FD_ISSET(fd, exceptfds))
+ if (exceptfds && FD_ISSET(fd, exceptfds)) {
events |= POLLERR | POLLHUP;
+ FD_CLR(fd, exceptfds);
+ }
if (events) {
pollfd info;
@@ -1060,10 +1056,6 @@ int KernelProxy::select(int nfds, fd_set* readfds, fd_set* writefds,
}
}
- FD_ZERO(readfds);
- FD_ZERO(writefds);
- FD_ZERO(exceptfds);
-
// NULL timeout signals wait forever.
int ms_timeout = -1;
if (timeout != NULL) {
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/event_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698