- if (FD_ISSET(fd, &input))
- mask += yaz_poll_read;
- if (FD_ISSET(fd, &output))
- mask += yaz_poll_write;
- if (FD_ISSET(fd, &except))
- mask += yaz_poll_except;
+ enum yaz_poll_mask mask = yaz_poll_none;
+ int fd = fds[i].fd;
+ if (!r)
+ yaz_poll_add(mask, yaz_poll_timeout);
+ else if (fd >= 0) {
+ if (FD_ISSET(fd, &input))
+ yaz_poll_add(mask, yaz_poll_read);
+ if (FD_ISSET(fd, &output))
+ yaz_poll_add(mask, yaz_poll_write);
+ if (FD_ISSET(fd, &except))
+ yaz_poll_add(mask, yaz_poll_except);
+ }
+ fds[i].output_mask = mask;