]> granicus.if.org Git - pdns/commitdiff
clear up local socket in rec_control in case recursor is down, close #2061
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 3 Feb 2015 09:39:40 +0000 (10:39 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 3 Feb 2015 09:39:40 +0000 (10:39 +0100)
pdns/rec_channel.cc
pdns/rec_control.cc

index e08484e8a3ce7f2837acb92327ab3b8c6feaf4ed..d566c06a71a49dbe936e3fd439e41359d0131f4d 100644 (file)
@@ -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);
index 86a8e8471cefafa8820d008244b12a03d66ab7a9..c282126bcfaf6204334f3b4e04b8859c80d78583 100644 (file)
@@ -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