aboutsummaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-07-20 22:37:34 +0200
committerMax Kellermann <max@duempel.org>2010-07-20 22:37:34 +0200
commita4908dca428dda7a3e83bfaf0d7e96d2b6242b73 (patch)
treeedf6b40048abbf296443b0f667552fd20f540942 /src/input
parent8b055c3127fb65aaeceb571b7db264c066b9cc3f (diff)
downloadmpd-a4908dca428dda7a3e83bfaf0d7e96d2b6242b73.tar.gz
mpd-a4908dca428dda7a3e83bfaf0d7e96d2b6242b73.tar.xz
mpd-a4908dca428dda7a3e83bfaf0d7e96d2b6242b73.zip
input/curl: query timeout from CURL
Use curl_multi_timeout() to determine the select() timeout, instead of hard-coding one second.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/curl_input_plugin.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/input/curl_input_plugin.c b/src/input/curl_input_plugin.c
index 43010c8bb..ff1ac85c5 100644
--- a/src/input/curl_input_plugin.c
+++ b/src/input/curl_input_plugin.c
@@ -241,7 +241,6 @@ input_curl_select(struct input_curl *c)
fd_set rfds, wfds, efds;
int max_fd, ret;
CURLMcode mcode;
- /* XXX hard coded timeout value.. */
struct timeval timeout = {
.tv_sec = 1,
.tv_usec = 0,
@@ -262,6 +261,24 @@ input_curl_select(struct input_curl *c)
assert(max_fd >= 0);
+#if LIBCURL_VERSION_NUM >= 0x070f00
+ long timeout2;
+ mcode = curl_multi_timeout(c->multi, &timeout2);
+ if (mcode != CURLM_OK) {
+ g_warning("curl_multi_timeout() failed: %s\n",
+ curl_multi_strerror(mcode));
+ return -1;
+ }
+
+ if (timeout2 >= 0) {
+ if (timeout2 > 10000)
+ timeout2 = 10000;
+
+ timeout.tv_sec = timeout2 / 1000;
+ timeout.tv_usec = (timeout2 % 1000) * 1000;
+ }
+#endif
+
ret = select(max_fd + 1, &rfds, &wfds, &efds, &timeout);
if (ret < 0)
g_warning("select() failed: %s\n", strerror(errno));