aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorWaldek Kozba <100assc@gmail.com>2014-10-07 12:53:59 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-11-19 13:28:48 +0100
commit9406ab91a2deffc09ad7951c7addc4153eb16df4 (patch)
treea2493aff4b352943674b885cf36b9b408bc8a4c1 /docs
parent29336986772dd4262ca85e8ef0120d3cbdf10a23 (diff)
multi-uv.c: close the file handle after download
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/multi-uv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c
index f91eb01c9..e1d727663 100644
--- a/docs/examples/multi-uv.c
+++ b/docs/examples/multi-uv.c
@@ -90,6 +90,7 @@ void add_download(const char *url, int num)
handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_WRITEDATA, file);
+ curl_easy_setopt(handle, CURLOPT_PRIVATE, file);
curl_easy_setopt(handle, CURLOPT_URL, url);
curl_multi_add_handle(curl_handle, handle);
fprintf(stderr, "Added download %s -> %s\n", url, filename);
@@ -101,16 +102,21 @@ static void check_multi_info(void)
char *done_url;
CURLMsg *message;
int pending;
+ FILE *file;
while ((message = curl_multi_info_read(curl_handle, &pending))) {
switch (message->msg) {
case CURLMSG_DONE:
curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL,
&done_url);
+ curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, &file);
printf("%s DONE\n", done_url);
curl_multi_remove_handle(curl_handle, message->easy_handle);
curl_easy_cleanup(message->easy_handle);
+ if (file) {
+ fclose(file);
+ }
break;
default: