]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
set async.done to TRUE last in the addrinfo callback to prevent the risk that
authorDaniel Stenberg <daniel@haxx.se>
Sun, 3 Oct 2004 21:32:24 +0000 (21:32 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 3 Oct 2004 21:32:24 +0000 (21:32 +0000)
the multi-threaded resolver does wrong

lib/hostasyn.c

index 2bf5a580a8324eacc9617b85b1a54c2e8c38d132..5a0397d7af6f4baa4af37a9abf23237cec741517 100644 (file)
@@ -115,7 +115,6 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */
   struct connectdata *conn = (struct connectdata *)arg;
   struct Curl_dns_entry *dns = NULL;
 
-  conn->async.done = TRUE;
   conn->async.status = status;
 
   if(CURL_ASYNC_SUCCESS == status) {
@@ -147,6 +146,11 @@ static void addrinfo_callback(void *arg, /* "struct connectdata *" */
 
   conn->async.dns = dns;
 
+ /* Set async.done TRUE last in this function since it may be used multi-
+    threaded and once this is TRUE the other thread may read fields from the
+    async struct */
+  conn->async.done = TRUE;
+
   /* ipv4: The input hostent struct will be freed by ares when we return from
      this function */
 }