- int fd = p->fd;
- int mask = 0;
- if (FD_ISSET(fd, &in))
- mask |= YAZ_SOCKET_OBSERVE_READ;
-
- if (FD_ISSET(fd, &out))
- mask |= YAZ_SOCKET_OBSERVE_WRITE;
-
- if (FD_ISSET(fd, &except))
- mask |= YAZ_SOCKET_OBSERVE_EXCEPT;
-
- if (mask)
- {
- YazSocketEvent *event = new YazSocketEvent;
- p->last_activity = now;
- event->observer = p->observer;
- event->event = mask;
- putEvent (event);
- }
- else if (res == 0 && p->timeout && p->timeout_this == timeout)
- {
- YazSocketEvent *event = new YazSocketEvent;
- assert (p->last_activity);
- yaz_log (m_log, "timeout, now = %ld last_activity=%ld timeout=%d",
- now, p->last_activity, p->timeout);
- p->last_activity = now;
- event->observer = p->observer;
- event->event = YAZ_SOCKET_OBSERVE_TIMEOUT;
- putEvent (event);
- }
+ fds[i].fd = p->fd;
+ int input_mask = 0;
+ if (p->mask & SOCKET_OBSERVE_READ)
+ input_mask += yaz_poll_read;
+ if (p->mask & SOCKET_OBSERVE_WRITE)
+ input_mask += yaz_poll_write;
+ if (p->mask & SOCKET_OBSERVE_EXCEPT)
+ input_mask += yaz_poll_except;
+ if (p->timeout > 0 ||
+ (p->timeout == 0 && (p->mask & SOCKET_OBSERVE_WRITE) == 0))
+ {
+ int timeout_this;
+ timeout_this = p->timeout;
+ if (p->last_activity)
+ timeout_this -= now - p->last_activity;
+ else
+ p->last_activity = now;
+ if (timeout_this < 0 || timeout_this > 2147483646)
+ timeout_this = 0;
+ if (timeout == -1 || timeout_this < timeout)
+ timeout = timeout_this;
+ p->timeout_this = timeout_this;
+ yaz_log (m_log, "SocketManager::select timeout_this=%d",
+ p->timeout_this);
+ }
+ else
+ p->timeout_this = -1;
+ fds[i].input_mask = (enum yaz_poll_mask) input_mask;