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