Permalink
Browse files

clear up local socket in rec_control in case recursor is down, close #…

  • Loading branch information...
1 parent f48d7b6 commit 524e4f4d81f4ed9eb218715cbc8a59f0b9868234 @ahupowerdns ahupowerdns committed Feb 3, 2015
Showing with 6 additions and 2 deletions.
  1. +5 −1 pdns/rec_channel.cc
  2. +1 −1 pdns/rec_control.cc
View
@@ -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);
View
@@ -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

0 comments on commit 524e4f4

Please sign in to comment.