X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;ds=sidebyside;f=src%2Feventl.c;h=1446da5f82d468479163f193c33dc8450a972bf1;hb=62d0f3042e380b729b560c653a5dc96978df7c78;hp=87bcecd6f483bb72b8c6b8bc9d15a4ce09a7b0e2;hpb=83875957712d17f110b1b7055fa26fcfb9c135e7;p=pazpar2-moved-to-github.git diff --git a/src/eventl.c b/src/eventl.c index 87bcecd..1446da5 100644 --- a/src/eventl.c +++ b/src/eventl.c @@ -231,8 +231,7 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { yaz_mutex_leave(man->iochan_mutex); inv_start = start; for (p = start; p; p = p->next) - if (p->fd >= 0) - no_fds++; + no_fds++; if (man->sel_fd != -1) no_fds++; if (no_fds > man->size_fds) @@ -246,25 +245,26 @@ 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) + 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; if (p->fd < 0) continue; - fds[i].fd = p->fd; - fds[i].input_mask = 0; if (p->flags & EVENT_INPUT) fds[i].input_mask |= yaz_poll_read; if (p->flags & EVENT_OUTPUT) fds[i].input_mask |= yaz_poll_write; if (p->flags & EVENT_EXCEPT) fds[i].input_mask |= yaz_poll_except; - i++; } yaz_log(man->log_level, "yaz_poll begin nofds=%d", no_fds); res = yaz_poll(fds, no_fds, to.tv_sec, 0); @@ -304,17 +304,16 @@ 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) + for (; i < no_fds; i++) { time_t now = time(0); + p = fds[i].client_data; if (p->destroyed) { yaz_log(man->log_level, "eventl: skip destroyed chan=%p name=%s", p, p->name ? p->name : ""); - if (p->fd >= 0) - i++; continue; } if (p->thread_users > 0) @@ -322,20 +321,16 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { yaz_log(man->log_level, "eventl: skip chan=%p name=%s users=%d", p, p->name ? p->name : "", p->thread_users); - if (p->fd >= 0) - i++; 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; @@ -351,7 +346,6 @@ static int event_loop(iochan_man_t man, IOCHAN *iochans) { p->last_event = now; p->this_event |= EVENT_EXCEPT; } - i++; } /* only fire one Z39.50/SRU socket event.. except for timeout */ if (p->this_event) {