]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/sys_generic.c
xnu-3789.31.2.tar.gz
[apple/xnu.git] / bsd / kern / sys_generic.c
index 8692d514df1325bc49e51759356f657124d860fd..bd8fd7c2291d3fe0593e30e02c5b85bb0e5b9c0b 100644 (file)
@@ -1778,8 +1778,15 @@ poll_nocancel(struct proc *p, struct poll_nocancel_args *uap, int32_t *retval)
                        fds[i].revents = 0;
        }
 
-       /* Did we have any trouble registering? */
-       if (rfds == nfds)
+       /*
+        * Did we have any trouble registering?
+        * If user space passed 0 FDs, then respect any timeout value passed.
+        * This is an extremely inefficient sleep. If user space passed one or
+        * more FDs, and we had trouble registering _all_ of them, then bail
+        * out. If a subset of the provided FDs failed to register, then we
+        * will still call the kqueue_scan function.
+        */
+       if (nfds && (rfds == nfds))
                goto done;
 
        /* scan for, and possibly wait for, the kevents to trigger */