1 diff --git a/src/liboping.c b/src/liboping.c
2 index 411d866..e80ea29 100644
5 @@ -590,9 +590,10 @@ static int ping_receive_one (pingobj_t *obj, const pinghost_t *ph,
7 static int ping_receive_all (pingobj_t *obj)
19 @@ -631,23 +632,25 @@ static int ping_receive_all (pingobj_t *obj)
26 + FD_ZERO (&read_fds);
31 for (ptr = ph; ptr != NULL; ptr = ptr->next)
33 if (!timerisset (ptr->timer))
36 - FD_SET (ptr->fd, &readfds);
38 + FD_SET (ptr->fd, &read_fds);
39 + FD_SET (ptr->fd, &err_fds);
42 - if (max_readfds < ptr->fd)
43 - max_readfds = ptr->fd;
44 + if (max_fd < ptr->fd)
48 - if (num_readfds == 0)
52 if (gettimeofday (&nowtime, NULL) == -1)
53 @@ -659,11 +662,11 @@ static int ping_receive_all (pingobj_t *obj)
54 if (ping_timeval_sub (&endtime, &nowtime, &timeout) == -1)
57 - dprintf ("Waiting on %i sockets for %i.%06i seconds\n", num_readfds,
58 + dprintf ("Waiting on %i sockets for %i.%06i seconds\n", num_fds,
60 (int) timeout.tv_usec);
62 - status = select (max_readfds + 1, &readfds, NULL, NULL, &timeout);
63 + status = select (max_fd + 1, &read_fds, NULL, &err_fds, &timeout);
65 if (gettimeofday (&nowtime, NULL) == -1)
67 @@ -696,9 +699,18 @@ static int ping_receive_all (pingobj_t *obj)
69 for (ptr = ph; ptr != NULL; ptr = ptr->next)
71 - if (FD_ISSET (ptr->fd, &readfds))
72 + if (FD_ISSET (ptr->fd, &read_fds))
74 if (ping_receive_one (obj, ptr, &nowtime) == 0)
77 + else if (FD_ISSET (ptr->fd, &err_fds))
79 + /* clear the timer in this case so that we
80 + * don't run into an endless loop. */
81 + /* TODO: Set an error flag in this case. */
82 + timerclear (ptr->timer);