#include <config.h>
#endif
+#include <math.h>
#include <stdio.h>
#include <assert.h>
new_iochan->fun = cb;
new_iochan->socketfun = NULL;
new_iochan->maskfun = NULL;
- new_iochan->force_event = 0;
new_iochan->last_event = new_iochan->max_idle = 0;
new_iochan->next = NULL;
new_iochan->man = 0;
IOCHAN p, *nextp;
fd_set in, out, except;
int res, max;
- static struct timeval nullto = {0, 0}, to;
+ static struct timeval to;
struct timeval *timeout;
FD_ZERO(&in);
to.tv_sec = p->max_idle;
if (p->fd < 0)
continue;
- if (p->force_event)
- timeout = &nullto; /* polling select */
if (p->flags & EVENT_INPUT)
FD_SET(p->fd, &in);
if (p->flags & EVENT_OUTPUT)
}
}
}
+ if (man->log_level)
+ {
+ int no = 0;
+ for (p = *iochans; p; p = p->next)
+ no++;
+ yaz_log(man->log_level, "%d channels", no);
+ }
for (p = *iochans; p; p = p->next)
{
- int force_event = p->force_event;
time_t now = time(0);
if (p->destroyed)
continue;
}
p->this_event = 0;
- p->force_event = 0;
- if ((p->max_idle && now - p->last_event > p->max_idle)
- || force_event == EVENT_TIMEOUT)
+ 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 (FD_ISSET(p->fd, &in) || force_event == EVENT_INPUT)
+ if (FD_ISSET(p->fd, &in))
{
p->last_event = now;
- yaz_log(YLOG_DEBUG, "Eventl input event");
p->this_event |= EVENT_INPUT;
}
- if (FD_ISSET(p->fd, &out) || force_event == EVENT_OUTPUT)
+ if (FD_ISSET(p->fd, &out))
{
p->last_event = now;
- yaz_log(YLOG_DEBUG, "Eventl output event");
p->this_event |= EVENT_OUTPUT;
}
- if (FD_ISSET(p->fd, &except) || force_event == EVENT_EXCEPT)
+ if (FD_ISSET(p->fd, &except))
{
p->last_event = now;
p->this_event |= EVENT_EXCEPT;
event_loop(man, &man->channel_list);
}
+void pazpar2_sleep(double d)
+{
+#ifdef WIN32
+ Sleep( (DWORD) (d * 1000));
+#else
+ struct timeval tv;
+ tv.tv_sec = floor(d);
+ tv.tv_usec = (d - floor(d)) * 1000000;
+ select(0, 0, 0, 0, &tv);
+#endif
+}
+
/*
* Local variables:
* c-basic-offset: 4