From 68edbc3e4a3f164a612437dd3ae4c57771a5fbb6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 25 Aug 2011 19:14:17 +0200 Subject: 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. --- src/input/curl_input_plugin.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/input/curl_input_plugin.c') 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; } -- cgit v1.2.3