aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/curl_input_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-08-25 19:14:17 +0200
committerMax Kellermann <max@duempel.org>2011-08-25 19:19:31 +0200
commit68edbc3e4a3f164a612437dd3ae4c57771a5fbb6 (patch)
treebae851009957c605e0620444eba73c5aa0517710 /src/input/curl_input_plugin.c
parent5068227a4684ba053db27e297ffb498e590f3e0d (diff)
downloadmpd-68edbc3e4a3f164a612437dd3ae4c57771a5fbb6.tar.gz
mpd-68edbc3e4a3f164a612437dd3ae4c57771a5fbb6.tar.xz
mpd-68edbc3e4a3f164a612437dd3ae4c57771a5fbb6.zip
input/curl: release "easy" CURL handle as early as possible
Release it immediately when end-of-file has been reached. We don't need that handle anymore, because the rest is delivered from the buffers.
Diffstat (limited to 'src/input/curl_input_plugin.c')
-rw-r--r--src/input/curl_input_plugin.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/input/curl_input_plugin.c b/src/input/curl_input_plugin.c
index e5e5cd941..76d8fe8f7 100644
--- a/src/input/curl_input_plugin.c
+++ b/src/input/curl_input_plugin.c
@@ -206,6 +206,9 @@ input_curl_easy_free(struct input_curl *c)
g_free(c->range);
c->range = NULL;
+
+ c->eof = true;
+ c->base.ready = true;
}
/**
@@ -250,12 +253,12 @@ input_curl_multi_info_read(struct input_curl *c, GError **error_r)
while ((msg = curl_multi_info_read(c->multi,
&msgs_in_queue)) != NULL) {
if (msg->msg == CURLMSG_DONE) {
- c->eof = true;
- c->base.ready = true;
+ CURLcode result = msg->data.result;
- if (msg->data.result != CURLE_OK) {
- g_set_error(error_r, curl_quark(),
- msg->data.result,
+ input_curl_easy_free(c);
+
+ if (result != CURLE_OK) {
+ g_set_error(error_r, curl_quark(), result,
"curl failed: %s", c->error);
return false;
}
@@ -346,8 +349,7 @@ fill_buffer(struct input_curl *c, GError **error_r)
g_set_error(error_r, curl_quark(), mcode,
"curl_multi_perform() failed: %s",
curl_multi_strerror(mcode));
- c->eof = true;
- c->base.ready = true;
+ input_curl_easy_free(c);
return false;
}
@@ -530,8 +532,7 @@ input_curl_buffer(struct input_stream *is, GError **error_r)
g_set_error(error_r, curl_quark(), mcode,
"curl_multi_perform() failed: %s",
curl_multi_strerror(mcode));
- c->eof = true;
- is->ready = true;
+ input_curl_easy_free(c);
return -1;
}