From 1d58071894904fae50f6c577963dbfd4c9b83062 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 25 Apr 2012 12:25:43 +0200 Subject: [PATCH] SocketManager deals with observers being lost during poll --- src/yaz-socket-manager.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index d872cf3..c3fc491 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -124,10 +124,21 @@ void SocketManager::inspect_poll_result(int res, struct yaz_poll_fd *fds, time_t now = time(0); int i; int no_put_events = 0; - SocketEntry *p; + int no_lost_observers = 0; - for (i = 0, p = m_observers; p; p = p->next, i++) + for (i = 0; i < no_fds; i++) { + SocketEntry *p; + for (p = m_observers; p; p = p->next) + if (p->fd == fds[i].fd) + break; + if (!p) + { + // m_observers list changed since poll started + no_lost_observers++; + continue; + } + enum yaz_poll_mask output_mask = fds[i].output_mask; int mask = 0; @@ -172,11 +183,14 @@ void SocketManager::inspect_poll_result(int res, struct yaz_poll_fd *fds, } else { - // bug #2035 - - 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); + if (no_lost_observers == 0) + { + // bug #2035 + 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); + } } } -- 1.7.10.4