Commit e6882ce4 authored by Andrei Sedoi's avatar Andrei Sedoi Committed by Daniel Stenberg
Browse files

docs: multi-uv: don't use CURLMsg after cleanup

parent b1aeed30
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -104,18 +104,25 @@ static void check_multi_info(void)
  char *done_url;
  char *done_url;
  CURLMsg *message;
  CURLMsg *message;
  int pending;
  int pending;
  CURL *easy_handle;
  FILE *file;
  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,
      /* Do not use message data after calling curl_multi_remove_handle() and
                        &done_url);
         curl_easy_cleanup(). As per curl_multi_info_read() docs:
      curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, &file);
         "WARNING: The data the returned pointer points to will not survive
         calling curl_multi_cleanup, curl_multi_remove_handle or
         curl_easy_cleanup." */
      easy_handle = message->easy_handle;

      curl_easy_getinfo(easy_handle, CURLINFO_EFFECTIVE_URL, &done_url);
      curl_easy_getinfo(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, easy_handle);
      curl_easy_cleanup(message->easy_handle);
      curl_easy_cleanup(easy_handle);
      if(file) {
      if(file) {
        fclose(file);
        fclose(file);
      }
      }