From 3aa91c3e82bbff18cc27679ce8d3b6b33c32baf1 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 5 Sep 2015 19:40:24 +0200 Subject: [PATCH] improve error message if attempting to bind to an address we can't bind to for outgoing queries --- pdns/pdns_recursor.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 0e30ebbfd..04cfea233 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -359,6 +359,7 @@ public: setCloseOnExec(ret); int tries=10; + ComboAddress sin; while(--tries) { uint16_t port; @@ -367,13 +368,13 @@ public: else port = 1025 + dns_random(64510); - ComboAddress sin=getQueryLocalAddress(family, port); // does htons for us + sin=getQueryLocalAddress(family, port); // does htons for us if (::bind(ret, (struct sockaddr *)&sin, sin.getSocklen()) >= 0) break; } if(!tries) - throw PDNSException("Resolver binding to local query client socket: "+stringerror()); + throw PDNSException("Resolver binding to local query client socket on "+sin.toString()+": "+stringerror()); setNonBlocking(ret); return ret; @@ -1341,6 +1342,16 @@ static void houseKeeping(void *) try { res=sr.beginResolve(".", QType(QType::NS), 1, ret); } + catch(PDNSException& e) + { + L<