Comparison

core/s2smanager.lua @ 3959:32a2a4f522f8

s2smanager: Handle DNS lookup error in response handler
author Matthew Wild <mwild1@gmail.com>
date Fri, 24 Dec 2010 04:57:17 +0000
parent 3958:8bd0b2d4b9b0
child 3960:bb8a064883fc
comparison
equal deleted inserted replaced
3958:8bd0b2d4b9b0 3959:32a2a4f522f8
286 end 286 end
287 287
288 function try_connect(host_session, connect_host, connect_port) 288 function try_connect(host_session, connect_host, connect_port)
289 host_session.connecting = true; 289 host_session.connecting = true;
290 local handle; 290 local handle;
291 handle = adns.lookup(function (reply) 291 handle = adns.lookup(function (reply, err)
292 handle = nil; 292 handle = nil;
293 host_session.connecting = nil; 293 host_session.connecting = nil;
294 294
295 -- COMPAT: This is a compromise for all you CNAME-(ab)users :) 295 -- COMPAT: This is a compromise for all you CNAME-(ab)users :)
296 if not (reply and reply[#reply] and reply[#reply].a) then 296 if not (reply and reply[#reply] and reply[#reply].a) then
309 return make_connect(host_session, reply[#reply].a, connect_port); 309 return make_connect(host_session, reply[#reply].a, connect_port);
310 else 310 else
311 log("debug", "DNS lookup failed to get a response for %s", connect_host); 311 log("debug", "DNS lookup failed to get a response for %s", connect_host);
312 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can 312 if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can
313 log("debug", "No other records to try for %s - destroying", host_session.to_host); 313 log("debug", "No other records to try for %s - destroying", host_session.to_host);
314 destroy_session(host_session, "DNS resolution failed"); -- End of the line, we can't 314 err = err and (": "..err) or "";
315 destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't
315 end 316 end
316 end 317 end
317 end, connect_host, "A", "IN"); 318 end, connect_host, "A", "IN");
318 319
319 return true; 320 return true;