net.dns: Remember query only after it was sent, in case it was not (fixes #598)
authorKim Alvefur <zash@zash.se>
Thu, 21 Jan 2016 21:26:46 +0000 (22:26 +0100)
committerKim Alvefur <zash@zash.se>
Thu, 21 Jan 2016 21:26:46 +0000 (22:26 +0100)
net/dns.lua

index f56157d07a9e15acb848a71d5f30b65eb4287bb8..d123731c14b578aeb26f3726d46908375ef4257f 100644 (file)
@@ -763,16 +763,16 @@ function resolver:query(qname, qtype, qclass)    -- - - - - - - - - - -- query
        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;