curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, ev);
}
+/* populate_fds()
+ *
+ * populate the fds[] array
+ */
+static unsigned int populate_fds(struct pollfd *fds, struct events *ev)
+{
+ unsigned int numfds = 0;
+ struct pollfd *f;
+ struct socketmonitor *m;
+
+ f = &fds[0];
+ for(m = ev->list; m; m = m->next) {
+ f->fd = m->socket.fd;
+ f->events = m->socket.events;
+ f->revents = 0;
+#if DEBUG_EV_POLL
+ fprintf(stderr, "poll() %d check socket %d\n", numfds, f->fd);
+#endif
+ f++;
+ numfds++;
+ }
+ return numfds;
+}
/* wait_or_timeout()
*
* waits for activity on any of the given sockets, or the timeout to trigger.
*/
-
static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
{
bool done = FALSE;
while(!done) {
CURLMsg *msg;
- struct socketmonitor *m;
- struct pollfd *f;
struct pollfd fds[4];
- int numfds = 0;
int pollrc;
- int i;
struct curltime before;
-
- /* populate the fds[] array */
- f = &fds[0];
- for(m = ev->list; m; m = m->next) {
- f->fd = m->socket.fd;
- f->events = m->socket.events;
- f->revents = 0;
-#if DEBUG_EV_POLL
- fprintf(stderr, "poll() %d check socket %d\n", numfds, f->fd);
-#endif
- f++;
- numfds++;
- }
+ const unsigned int numfds = populate_fds(fds, ev);
/* get the time stamp to use to figure out how long poll takes */
before = Curl_now();
if(numfds) {
/* wait for activity or timeout */
#if DEBUG_EV_POLL
- fprintf(stderr, "poll(numfds=%d, timeout=%ldms)\n", numfds, ev->ms);
+ fprintf(stderr, "poll(numfds=%u, timeout=%ldms)\n", numfds, ev->ms);
#endif
- pollrc = Curl_poll(fds, (unsigned int)numfds, ev->ms);
+ pollrc = Curl_poll(fds, numfds, ev->ms);
#if DEBUG_EV_POLL
- fprintf(stderr, "poll(numfds=%d, timeout=%ldms) -> %d\n",
+ fprintf(stderr, "poll(numfds=%u, timeout=%ldms) -> %d\n",
numfds, ev->ms, pollrc);
#endif
if(pollrc < 0)
/* here pollrc is > 0 */
struct Curl_llist_node *e = Curl_llist_head(&multi->process);
struct Curl_easy *data;
+ unsigned int i;
DEBUGASSERT(e);
data = Curl_node_elem(e);
DEBUGASSERT(data);