From 401cc36924585ce8292212c73dc8aab372056620 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 11 Nov 2015 10:38:17 +0000 Subject: [PATCH] Add extra logging to curl poll fn when not suppressing curl debug. --- content/fetchers/curl.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index 624cdbf41..4f5da3cf6 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -1006,6 +1006,44 @@ static void fetch_curl_poll(lwc_string *scheme_ignored) CURLMcode codem; CURLMsg *curl_msg; + if (nsoption_bool(suppress_curl_debug) == false) { + fd_set read_fd_set, write_fd_set, exc_fd_set; + int max_fd = -1; + int i; + + FD_ZERO(&read_fd_set); + FD_ZERO(&write_fd_set); + FD_ZERO(&exc_fd_set); + + codem = curl_multi_fdset(fetch_curl_multi, + &read_fd_set, &write_fd_set, + &exc_fd_set, &max_fd); + assert(codem == CURLM_OK); + + LOG("Curl file descriptor states (maxfd=%i):", max_fd); + for (i = 0; i <= max_fd; i++) { + bool read = false; + bool write = false; + bool error = false; + + if (FD_ISSET(i, &read_fd_set)) { + read = true; + } + if (FD_ISSET(i, &write_fd_set)) { + write = true; + } + if (FD_ISSET(i, &exc_fd_set)) { + error = true; + } + if (read || write || error) { + LOG(" fd %*i: %s %s %s", max_fd / 10 + 1, i, + read ? "read" : " ", + write ? "write" : " ", + error ? "error" : " "); + } + } + } + /* do any possible work on the current fetches */ do { codem = curl_multi_perform(fetch_curl_multi, &running);