- for (p = *iochans; p; p = p->next)
- {
- int force_event = p->force_event;
-
- p->force_event = 0;
- if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
- force_event == EVENT_INPUT))
- {
- p->last_event = now;
- (*p->fun)(p, EVENT_INPUT);
- }
- if (!p->destroyed && (FD_ISSET(p->fd, &out) ||
- force_event == EVENT_OUTPUT))
- {
- p->last_event = now;
- (*p->fun)(p, EVENT_OUTPUT);
- }
- if (!p->destroyed && (FD_ISSET(p->fd, &except) ||
- force_event == EVENT_EXCEPT))
- {
- p->last_event = now;
- (*p->fun)(p, EVENT_EXCEPT);
- }
- if (!p->destroyed && ((p->max_idle && now - p->last_event >=
- p->max_idle) || force_event == EVENT_TIMEOUT))
- {
- p->last_event = now;
- (*p->fun)(p, EVENT_TIMEOUT);
- }
- }
- for (p = *iochans; p; p = nextp)
- {
- nextp = p->next;
-
- if (p->destroyed)
- {
- IOCHAN tmp = p, pr;
+ for (i = 0, p = *iochans; p; p = p->next, i++)
+ {
+ int force_event = p->force_event;
+ enum yaz_poll_mask output_mask = fds[i].output_mask;
+
+ p->force_event = 0;
+ if (!p->destroyed && ((output_mask & yaz_poll_read) ||
+ force_event == EVENT_INPUT))
+ {
+ p->last_event = now;
+ (*p->fun)(p, EVENT_INPUT);
+ }
+ if (!p->destroyed && ((output_mask & yaz_poll_write) ||
+ force_event == EVENT_OUTPUT))
+ {
+ p->last_event = now;
+ (*p->fun)(p, EVENT_OUTPUT);
+ }
+ if (!p->destroyed && ((output_mask & yaz_poll_except) ||
+ force_event == EVENT_EXCEPT))
+ {
+ p->last_event = now;
+ (*p->fun)(p, EVENT_EXCEPT);
+ }
+ if (!p->destroyed && ((p->max_idle && now - p->last_event >=
+ p->max_idle) || force_event == EVENT_TIMEOUT))
+ {
+ p->last_event = now;
+ (*p->fun)(p, EVENT_TIMEOUT);
+ }
+ }
+ xfree(fds);
+ for (p = *iochans; p; p = nextp)
+ {
+ nextp = p->next;
+
+ if (p->destroyed)
+ {
+ IOCHAN tmp = p, pr;