52 #include <yaz/yconfig.h>
54 #include <yaz/comstack.h>
55 #include <yaz/xmalloc.h>
56 #include <yaz/mutex.h>
77 yaz_log(YLOG_DEBUG,
"%s iochans=%d", delta == 0 ?
"" : (delta > 0 ?
"INC" :
"DEC"), iochans);
96 #define iochans_count(x) 0
97 #define iochans_count_total(x) 0
115 man->
log_level = yaz_log_module_level(
"iochan");
134 if ((*mp)->sel_thread)
137 yaz_mutex_enter((*mp)->iochan_mutex);
138 c = (*mp)->channel_list;
139 (*mp)->channel_list = NULL;
140 yaz_mutex_leave((*mp)->iochan_mutex);
144 yaz_mutex_destroy(&(*mp)->iochan_mutex);
153 yaz_log(man->
log_level,
"iochan_add : chan=%p channel list=%p", chan,
163 if (!(new_iochan = (
IOCHAN) xmalloc(
sizeof(*new_iochan))))
168 new_iochan->
flags = flags;
169 new_iochan->
fun = cb;
171 new_iochan->
next = NULL;
174 new_iochan->
name = name ? xstrdup(name) : 0;
181 yaz_log(p->
man->
log_level,
"eventl: work begin chan=%p name=%s event=%d",
193 yaz_log(p->
man->
log_level,
"eventl: work end chan=%p name=%s event=%d", p,
201 "eventl: work add chan=%p name=%s event=%d", p,
216 fd_set in, out, except;
218 static struct timeval to;
219 struct timeval *timeout;
236 for (p = start; p; p = p->
next) {
242 for (p = start; p; p = p->
next) {
254 FD_SET(p->
fd, &except);
265 yaz_log(man->
log_level,
"select begin nofds=%d", max);
266 res = select(max + 1, &in, &out, &except, timeout);
267 yaz_log(man->
log_level,
"select returned res=%d", res);
272 yaz_log(YLOG_ERRNO | YLOG_WARN,
"select");
277 if (FD_ISSET(man->
sel_fd, &in)) {
280 yaz_log(man->
log_level,
"eventl: sel input on sel_fd=%d",
284 "eventl: got thread result chan=%p name=%s", chan,
292 for (p = start; p; p = p->
next) {
295 yaz_log(man->
log_level,
"%d channels", no);
297 for (p = start; p; p = p->
next) {
298 time_t now = time(0);
302 "eventl: skip destroyed chan=%p name=%s", p,
308 "eventl: skip chan=%p name=%s users=%d", p,
319 if (FD_ISSET(p->
fd, &in)) {
323 if (FD_ISSET(p->
fd, &out)) {
327 if (FD_ISSET(p->
fd, &except)) {
334 assert(inv_start == start);
336 for (nextp = iochans; *nextp;) {
352 yaz_log(man->
log_level,
"iochan_man_events. Using %d threads",
360 Sleep( (DWORD) (d * 1000));
363 tv.tv_sec = floor(d);
364 tv.tv_usec = (d - floor(d)) * 1000000;
365 select(0, 0, 0, 0, &tv);