mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
multi-uv.c: close the file handle after download
This commit is contained in:
parent
2933698677
commit
9406ab91a2
@ -90,6 +90,7 @@ void add_download(const char *url, int num)
|
|||||||
|
|
||||||
handle = curl_easy_init();
|
handle = curl_easy_init();
|
||||||
curl_easy_setopt(handle, CURLOPT_WRITEDATA, file);
|
curl_easy_setopt(handle, CURLOPT_WRITEDATA, file);
|
||||||
|
curl_easy_setopt(handle, CURLOPT_PRIVATE, file);
|
||||||
curl_easy_setopt(handle, CURLOPT_URL, url);
|
curl_easy_setopt(handle, CURLOPT_URL, url);
|
||||||
curl_multi_add_handle(curl_handle, handle);
|
curl_multi_add_handle(curl_handle, handle);
|
||||||
fprintf(stderr, "Added download %s -> %s\n", url, filename);
|
fprintf(stderr, "Added download %s -> %s\n", url, filename);
|
||||||
@ -101,16 +102,21 @@ static void check_multi_info(void)
|
|||||||
char *done_url;
|
char *done_url;
|
||||||
CURLMsg *message;
|
CURLMsg *message;
|
||||||
int pending;
|
int pending;
|
||||||
|
FILE *file;
|
||||||
|
|
||||||
while ((message = curl_multi_info_read(curl_handle, &pending))) {
|
while ((message = curl_multi_info_read(curl_handle, &pending))) {
|
||||||
switch (message->msg) {
|
switch (message->msg) {
|
||||||
case CURLMSG_DONE:
|
case CURLMSG_DONE:
|
||||||
curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL,
|
curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL,
|
||||||
&done_url);
|
&done_url);
|
||||||
|
curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, &file);
|
||||||
printf("%s DONE\n", done_url);
|
printf("%s DONE\n", done_url);
|
||||||
|
|
||||||
curl_multi_remove_handle(curl_handle, message->easy_handle);
|
curl_multi_remove_handle(curl_handle, message->easy_handle);
|
||||||
curl_easy_cleanup(message->easy_handle);
|
curl_easy_cleanup(message->easy_handle);
|
||||||
|
if (file) {
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user