From c484185f197c887fb24cdbbd1afa2f425a963d18 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Thu, 27 Oct 2005 17:12:42 +0000 Subject: [PATCH] loop over poll event entries if the total number is larger than supported This commit was SVN r7898. --- opal/event/poll.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/opal/event/poll.c b/opal/event/poll.c index d0503ce842..f66745e846 100644 --- a/opal/event/poll.c +++ b/opal/event/poll.c @@ -127,7 +127,7 @@ poll_recalc(void *arg, int max) static int poll_dispatch(void *arg, struct timeval *tv) { - int res, i, count, sec, nfds; + int res, i, offset, count, sec, nfds; struct opal_event *ev; struct pollop *pop = arg; @@ -183,9 +183,27 @@ poll_dispatch(void *arg, struct timeval *tv) return (-1); #endif - sec = tv->tv_sec * 1000 + tv->tv_usec / 1000; opal_mutex_unlock(&opal_event_lock); - res = poll(pop->event_set, nfds, sec); + offset = 0; + res = 0; + count = nfds; + while(count > 0) { + int num = (count > FD_SETSIZE) ? FD_SETSIZE : count; + int ret; + sec = tv->tv_sec * 1000 + tv->tv_usec / 1000; + ret = poll(pop->event_set + offset, num, sec); + if (res == -1) { + if (errno != EINTR) { + opal_output(0, "poll failed with errno=%d\n", errno); + opal_mutex_lock(&opal_event_lock); + return (-1); + } + } else { + res += ret; + } + offset += num; + count -= num; + } opal_mutex_lock(&opal_event_lock); #if OPAL_EVENT_USE_SIGNALS @@ -193,18 +211,6 @@ poll_dispatch(void *arg, struct timeval *tv) return (-1); #endif - if (res == -1) { - if (errno != EINTR) { - opal_output(0, "poll failed with errno=%d\n", errno); - return (-1); - } - -#if OPAL_EVENT_USE_SIGNALS - opal_evsignal_process(); -#endif - return (0); - } - #if OPAL_EVENT_USE_SIGNALS else if (opal_evsignal_caught) opal_evsignal_process();