Permalink
Browse files

only setCloseOnExec on valid sockets

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3067 d19b8d6e-7fed-0310-83ef-9ca221ded41b
  • Loading branch information...
1 parent ebe9c81 commit fb31631870b0330a5228f975ebb5145589486d86 @Habbie Habbie committed Jan 21, 2013
Showing with 6 additions and 3 deletions.
  1. +2 −1 pdns/nameserver.cc
  2. +4 −2 pdns/tcpreceiver.cc
View
@@ -165,10 +165,11 @@ void UDPNameserver::bindIPv6()
string localname(*i);
s=socket(AF_INET6,SOCK_DGRAM,0);
- Utility::setCloseOnExec(s);
if(s<0)
throw AhuException("Unable to acquire a UDPv6 socket: "+string(strerror(errno)));
+ Utility::setCloseOnExec(s);
+
ComboAddress locala(localname, ::arg().asNum("local-port"));
if(IsAnyAddress(locala)) {
View
@@ -834,11 +834,12 @@ TCPNameserver::TCPNameserver()
for(vector<string>::const_iterator laddr=locals.begin();laddr!=locals.end();++laddr) {
int s=socket(AF_INET,SOCK_STREAM,0);
- Utility::setCloseOnExec(s);
if(s<0)
throw AhuException("Unable to acquire TCP socket: "+stringerror());
+ Utility::setCloseOnExec(s);
+
ComboAddress local(*laddr, ::arg().asNum("local-port"));
int tmp=1;
@@ -866,11 +867,12 @@ TCPNameserver::TCPNameserver()
#if !WIN32 && HAVE_IPV6
for(vector<string>::const_iterator laddr=locals6.begin();laddr!=locals6.end();++laddr) {
int s=socket(AF_INET6,SOCK_STREAM,0);
- Utility::setCloseOnExec(s);
if(s<0)
throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
+ Utility::setCloseOnExec(s);
+
ComboAddress local(*laddr, ::arg().asNum("local-port"));
int tmp=1;

0 comments on commit fb31631

Please sign in to comment.