From: bert hubert Date: Tue, 3 Feb 2015 09:39:40 +0000 (+0100) Subject: clear up local socket in rec_control in case recursor is down, close #2061 X-Git-Tag: rec-3.7.0-rc2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=524e4f4d81f4ed9eb218715cbc8a59f0b9868234;p=thirdparty%2Fpdns.git clear up local socket in rec_control in case recursor is down, close #2061 --- diff --git a/pdns/rec_channel.cc b/pdns/rec_channel.cc index e08484e8a3..d566c06a71 100644 --- a/pdns/rec_channel.cc +++ b/pdns/rec_channel.cc @@ -68,6 +68,7 @@ void RecursorControlChannel::connect(const string& path, const string& fname) throw PDNSException("Setsockopt failed: "+stringerror()); string localname=path+"/lsockXXXXXX"; + *d_local.sun_path=0; if (makeUNsockaddr(localname, &d_local)) throw PDNSException("Unable to bind to local temporary file, path '"+localname+"' is not a valid UNIX socket path."); @@ -88,8 +89,11 @@ void RecursorControlChannel::connect(const string& path, const string& fname) if (makeUNsockaddr(remotename, &remote)) throw PDNSException("Unable to connect to controlsocket, path '"+remotename+"' is not a valid UNIX socket path."); - if(::connect(d_fd, (sockaddr*)&remote, sizeof(remote)) < 0) + if(::connect(d_fd, (sockaddr*)&remote, sizeof(remote)) < 0) { + if(*d_local.sun_path) + unlink(d_local.sun_path); throw PDNSException("Unable to connect to remote '"+string(remote.sun_path)+"': "+stringerror()); + } } catch (...) { close(d_fd); diff --git a/pdns/rec_control.cc b/pdns/rec_control.cc index 86a8e8471c..c282126bcf 100644 --- a/pdns/rec_control.cc +++ b/pdns/rec_control.cc @@ -1,6 +1,6 @@ /* PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2006 - 2011 PowerDNS.COM BV + Copyright (C) 2006 - 2015 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as