summaryrefslogtreecommitdiff
path: root/lib/hostasyn.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-10-03 21:32:24 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-10-03 21:32:24 +0000
commit2ee6c334126b257708ac92b19c57701e18bb31cc (patch)
tree5feb9795b80a6cbb78bbf8c66e6e985e45744f14 /lib/hostasyn.c
parentbe7ce435c036f893f6ce04c91d1cbec006a810e5 (diff)
downloadcurl-2ee6c334126b257708ac92b19c57701e18bb31cc.tar.gz
set async.done to TRUE last in the addrinfo callback to prevent the risk that
the multi-threaded resolver does wrong
Diffstat (limited to 'lib/hostasyn.c')
-rw-r--r--lib/hostasyn.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/hostasyn.c b/lib/hostasyn.c
index 2bf5a580a..5a0397d7a 100644
--- a/lib/hostasyn.c
+++ b/lib/hostasyn.c
@@ -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 */
}