From 62d0f3042e380b729b560c653a5dc96978df7c78 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 13 Aug 2014 11:53:51 +0200 Subject: [PATCH] event loop fixes for threaded operation PAZ-947 --- src/eventl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/eventl.c b/src/eventl.c index 77745b6..1446da5 100644 --- a/src/eventl.c +++ b/src/eventl.c @@ -245,16 +245,18 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { { fds[i].fd = man->sel_fd; fds[i].input_mask = yaz_poll_read; + fds[i].client_data = 0; i++; } for (p = start; p; p = p->next, i++) { + fds[i].client_data = p; + fds[i].fd = p->fd; + fds[i].input_mask = 0; if (p->thread_users > 0) continue; if (p->max_idle && p->max_idle < to.tv_sec) to.tv_sec = p->max_idle; - fds[i].fd = p->fd; - fds[i].input_mask = 0; if (p->fd < 0) continue; if (p->flags & EVENT_INPUT) @@ -302,9 +304,10 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { no++; yaz_log(man->log_level, "%d channels", no); } - for (p = start; p; p = p->next, i++) + for (; i < no_fds; i++) { time_t now = time(0); + p = fds[i].client_data; if (p->destroyed) { @@ -321,15 +324,13 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { 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 (p->fd >= 0) + if (fds[i].fd >= 0) { - assert(fds[i].fd == p->fd); if (fds[i].output_mask & yaz_poll_read) { p->last_event = now; -- 1.7.10.4