- int fd = p->fd;
- if (p->mask)
- no++;
- if (p->mask & YAZ_SOCKET_OBSERVE_READ)
- FD_SET(fd, &in);
- if (p->mask & YAZ_SOCKET_OBSERVE_WRITE)
- FD_SET(fd, &out);
- if (p->mask & YAZ_SOCKET_OBSERVE_EXCEPT)
- FD_SET(fd, &except);
- if (fd > max)
- max = fd;
- if (p->timeout)
- {
- unsigned timeout_this;
- timeout_this = p->timeout;
- if (p->last_activity)
- timeout_this -= now - p->last_activity;
- if (timeout_this < 1)
- timeout_this = 1;
- if (!timeout || timeout_this < timeout)
- timeout = timeout_this;
- }
+ int fd = p->fd;
+ if (p->mask)
+ no++;
+ if (p->mask & SOCKET_OBSERVE_READ)
+ {
+ yaz_log (m_log, "SocketManager::select fd=%d read", fd);
+ FD_SET(fd, &in);
+ }
+ if (p->mask & SOCKET_OBSERVE_WRITE)
+ {
+ yaz_log (m_log, "SocketManager::select fd=%d write", fd);
+ FD_SET(fd, &out);
+ }
+ if (p->mask & SOCKET_OBSERVE_EXCEPT)
+ {
+ yaz_log (m_log, "SocketManager::select fd=%d except", fd);
+ FD_SET(fd, &except);
+ }
+ if (fd > max)
+ max = fd;
+ 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;