- if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
- force_event == EVENT_INPUT))
- {
- p->last_event = now;
- yaz_log(YLOG_DEBUG, "Eventl input event");
- run_fun(man, p, EVENT_INPUT);
- }
- if (!p->destroyed && (FD_ISSET(p->fd, &out) ||
- force_event == EVENT_OUTPUT))
- {
- p->last_event = now;
- yaz_log(YLOG_DEBUG, "Eventl output event");
- run_fun(man, p, EVENT_OUTPUT);
- }
- if (!p->destroyed && (FD_ISSET(p->fd, &except) ||
- force_event == EVENT_EXCEPT))
- {
- p->last_event = now;
- run_fun(man, p, EVENT_EXCEPT);
- }
- }
- for (p = *iochans; p; p = nextp)
- {
- nextp = p->next;
-
- if (p->destroyed)
- {
- IOCHAN tmp = p, pr;
-
- /* Now reset the pointers */
- if (p == *iochans)
- *iochans = p->next;
- else
- {
- for (pr = *iochans; pr; pr = pr->next)
- if (pr->next == p)
- break;
- assert(pr); /* grave error if it weren't there */
- pr->next = p->next;
- }
- if (nextp == p)
- nextp = p->next;
- xfree(tmp);
- }
- }
- }
- while (*iochans);
+ }
+ if (p->thread_users > 0)
+ {
+ yaz_log(man->log_level,
+ "eventl: skip chan=%p name=%s users=%d", p,
+ p->name ? p->name : "", p->thread_users);
+ continue;
+ }
+ p->this_event = 0;
+ if (p->max_idle && now - p->last_event > p->max_idle)
+ {
+ p->last_event = now;
+ p->this_event |= EVENT_TIMEOUT;
+ }
+ if (fds[i].fd >= 0 && p->fd == fds[i].fd)
+ {
+ if (fds[i].output_mask & yaz_poll_read)
+ {
+ p->last_event = now;
+ p->this_event |= EVENT_INPUT;
+ }
+ if (fds[i].output_mask & yaz_poll_write)
+ {
+ p->last_event = now;
+ p->this_event |= EVENT_OUTPUT;
+ }
+ if (fds[i].output_mask & yaz_poll_except)
+ {
+ p->last_event = now;
+ p->this_event |= EVENT_EXCEPT;
+ }
+ }
+ /* only fire one Z39.50/SRU socket event.. except for timeout */
+ if (p->this_event)
+ {
+ if (!(p->this_event & EVENT_TIMEOUT) &&
+ !strcmp(p->name, "connection_socket"))
+ {
+ /* not a timeout and we have a Z39.50/SRU socket */
+ if (connection_fired == 0)
+ run_fun(man, p);
+ connection_fired++;
+ }
+ else
+ run_fun(man, p);
+ }
+ }
+
+ assert(inv_start == start);
+ yaz_mutex_enter(man->iochan_mutex);
+ for (nextp = iochans; *nextp; )
+ {
+ IOCHAN p = *nextp;
+ if (p->destroyed && p->thread_users == 0)
+ *nextp = iochan_destroy_real(p);
+ else
+ nextp = &p->next;
+ }
+ yaz_mutex_leave(man->iochan_mutex);
+ } while (*iochans);