- debug("selecting...\n");
- ready = select(maxfd + 1, &fds, NULL, NULL, NULL);
- debug("ready: %d\n", ready);
- assert(ready != 0);
- if (ready < 0)
- /* TODO: Do we really want to fail here? */
- fatal("%s", strerror(errno));
- while (ready) {
+ khlib_debug("selecting...\n");
+ ready = pselect(maxfd + 1, &fds, NULL, NULL, ti, NULL);
+ khlib_debug("ready: %d\n", ready);
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ if (ready == -1) {
+ switch (errno) {
+ case EINTR:
+ khlib_error(
+ "pselect temp failure: %d, errno: %d, msg: %s\n",
+ ready,
+ errno,
+ strerror(errno)
+ );
+ /* TODO: Reconsider what to do here. */
+ return;
+ default:
+ khlib_fatal(
+ "pselect failed: %d, errno: %d, msg: %s\n",
+ ready,
+ errno,
+ strerror(errno)
+ );
+ }
+ }
+ /* At-least-once ensures that expiries are still checked on timeouts. */
+ do {