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;
+ /*
+ * If any events have trouble registering, an event has fired and we
+ * shouldn't wait for events in kqueue_scan -- use the current time as
+ * the deadline.
+ */
+ if (rfds)
+ getmicrouptime(&atv);
+
/* scan for, and possibly wait for, the kevents to trigger */
cont->pca_fds = uap->fds;
cont->pca_nfds = nfds;
error = copyin(args->arg3, (char *)&len, sizeof (len));
else if (args->cmd == LEDGER_TEMPLATE_INFO)
error = copyin(args->arg2, (char *)&len, sizeof (len));
-#ifdef LEDGER_DEBUG
else if (args->cmd == LEDGER_LIMIT)
+#ifdef LEDGER_DEBUG
error = copyin(args->arg2, (char *)&lla, sizeof (lla));
+#else
+ return (EINVAL);
#endif
else if ((args->cmd < 0) || (args->cmd > LEDGER_MAX_CMD))
return (EINVAL);