aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-03 21:49:43 +0100
committerMax Kellermann <max@duempel.org>2008-11-03 21:49:43 +0100
commit75d2a3976877ef609793ca888c633f37418669a3 (patch)
treee783f9795411d996a920fac5c1795dde9977eb7d
parentfdf0d46e3d0e14fe0ad0ff112b738f4b5cdf04a4 (diff)
downloadmpd-75d2a3976877ef609793ca888c633f37418669a3.tar.gz
mpd-75d2a3976877ef609793ca888c633f37418669a3.tar.xz
mpd-75d2a3976877ef609793ca888c633f37418669a3.zip
input_curl: use curl_multi_info_read()
The function curl_multi_info_read() provides access to errors from the curl easy interface.
-rw-r--r--src/input_curl.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/input_curl.c b/src/input_curl.c
index 7a6875ff8..50c837fdb 100644
--- a/src/input_curl.c
+++ b/src/input_curl.c
@@ -143,6 +143,27 @@ input_curl_free(struct input_stream *is)
g_free(c);
}
+static bool
+input_curl_multi_info_read(struct input_stream *is)
+{
+ struct input_curl *c = is->data;
+ CURLMsg *msg;
+ int msgs_in_queue;
+
+ while ((msg = curl_multi_info_read(c->multi,
+ &msgs_in_queue)) != NULL) {
+ if (msg->msg == CURLMSG_DONE &&
+ msg->data.result != CURLE_OK) {
+ g_warning("curl failed: %s\n",
+ curl_easy_strerror(msg->data.result));
+ c->eof = true;
+ return false;
+ }
+ }
+
+ return true;
+}
+
/**
* Wait for the libcurl socket.
*
@@ -220,6 +241,7 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size)
while (!c->eof && list_empty(&c->buffers)) {
int running_handles;
+ bool bret;
if (mcode != CURLM_CALL_MULTI_PERFORM) {
/* if we're still here, there is no input yet
@@ -238,6 +260,10 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size)
return 0;
}
+ bret = input_curl_multi_info_read(is);
+ if (!bret)
+ return -1;
+
c->eof = running_handles == 0;
}
@@ -292,11 +318,12 @@ input_curl_eof(mpd_unused struct input_stream *is)
}
static int
-input_curl_buffer(mpd_unused struct input_stream *is)
+input_curl_buffer(struct input_stream *is)
{
struct input_curl *c = is->data;
CURLMcode mcode;
int running_handles;
+ bool ret;
c->buffered = false;
@@ -311,6 +338,10 @@ input_curl_buffer(mpd_unused struct input_stream *is)
return -1;
}
+ ret = input_curl_multi_info_read(is);
+ if (!ret)
+ return -1;
+
c->eof = running_handles == 0;
return c->buffered;