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.");
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);
/*
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