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.
This commit is contained in:
Max Kellermann 2011-08-25 19:14:17 +02:00
parent 5068227a46
commit 68edbc3e4a

View File

@ -206,6 +206,9 @@ input_curl_easy_free(struct input_curl *c)
g_free(c->range); g_free(c->range);
c->range = NULL; 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, while ((msg = curl_multi_info_read(c->multi,
&msgs_in_queue)) != NULL) { &msgs_in_queue)) != NULL) {
if (msg->msg == CURLMSG_DONE) { if (msg->msg == CURLMSG_DONE) {
c->eof = true; CURLcode result = msg->data.result;
c->base.ready = true;
if (msg->data.result != CURLE_OK) { input_curl_easy_free(c);
g_set_error(error_r, curl_quark(),
msg->data.result, if (result != CURLE_OK) {
g_set_error(error_r, curl_quark(), result,
"curl failed: %s", c->error); "curl failed: %s", c->error);
return false; return false;
} }
@ -346,8 +349,7 @@ fill_buffer(struct input_curl *c, GError **error_r)
g_set_error(error_r, curl_quark(), mcode, g_set_error(error_r, curl_quark(), mcode,
"curl_multi_perform() failed: %s", "curl_multi_perform() failed: %s",
curl_multi_strerror(mcode)); curl_multi_strerror(mcode));
c->eof = true; input_curl_easy_free(c);
c->base.ready = true;
return false; return false;
} }
@ -530,8 +532,7 @@ input_curl_buffer(struct input_stream *is, GError **error_r)
g_set_error(error_r, curl_quark(), mcode, g_set_error(error_r, curl_quark(), mcode,
"curl_multi_perform() failed: %s", "curl_multi_perform() failed: %s",
curl_multi_strerror(mcode)); curl_multi_strerror(mcode));
c->eof = true; input_curl_easy_free(c);
is->ready = true;
return -1; return -1;
} }