/* This file is part of the yazpp toolkit.
- * Copyright (C) 1998-2009 Index Data and Mike Taylor
+ * Copyright (C) 1998-2012 Index Data and Mike Taylor
* See the file LICENSE for details.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
return se;
}
+int SocketManager::getNumberOfObservers()
+{
+ int i = 0;
+ SocketEntry *se;
+ for (se = m_observers; se; se = se->next, i++)
+ ;
+ return i;
+}
+
void SocketManager::addObserver(int fd, ISocketObserver *observer)
{
SocketEntry *se;
yaz_log(YLOG_WARN, "unhandled socket event. yaz_poll returned %d", res);
yaz_log(YLOG_WARN, "no_put_events=%d no_fds=%d i=%d timeout=%d",
no_put_events, no_fds, i, timeout);
- abort();
}
}
}
int pass = 0;
- while ((res = yaz_poll(fds, no_fds, timeout, 0)) < 0)
+ while ((res = yaz_poll(fds, no_fds, timeout, 0)) < 0 && pass < 10)
{
- if (errno != EINTR)
- {
- yaz_log(YLOG_ERRNO|YLOG_WARN, "yaz_poll");
- yaz_log(YLOG_WARN, "errno=%d timeout=%d", errno, timeout);
- if (++pass > 10)
- return -1;
- }
+ if (errno == EINTR)
+ continue;
+ yaz_log(YLOG_ERRNO|YLOG_WARN, "yaz_poll");
+ yaz_log(YLOG_WARN, "errno=%d timeout=%d", errno, timeout);
}
- inspect_poll_result(res, fds, no_fds, timeout);
+ if (res >= 0)
+ inspect_poll_result(res, fds, no_fds, timeout);
delete [] fds;
- return 1;
+ return res >= 0 ? 1 : -1;
}