# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1453411606 -3600
# Node ID 388281be2bc7383d2b6b9378aa58709b623eda1b
# Parent  bee63de4966327eb6d48fecb8ab9ed2909274e94
net.dns: Remember query only after it was sent, in case it was not (fixes #598)

diff -r bee63de49663 -r 388281be2bc7 net/dns.lua
--- a/net/dns.lua	Thu Jan 21 22:21:19 2016 +0100
+++ b/net/dns.lua	Thu Jan 21 22:26:46 2016 +0100
@@ -763,16 +763,16 @@
 	self.active[id] = self.active[id] or {};
 	self.active[id][question] = o;
 
-	-- remember which coroutine wants the answer
-	if co then
-		set(self.wanted, qclass, qtype, qname, co, true);
-	end
-
 	local conn, err = self:getsocket(o.server)
 	if not conn then
 		return nil, err;
 	end
 	conn:send (o.packet)
+
+	-- remember which coroutine wants the answer
+	if co then
+		set(self.wanted, qclass, qtype, qname, co, true);
+	end
 	
 	if timer and self.timeout then
 		local num_servers = #self.server;