]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add the TCP socket to the map only if the connection succeeds 4734/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sun, 4 Dec 2016 20:09:37 +0000 (21:09 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sun, 4 Dec 2016 20:11:01 +0000 (21:11 +0100)
Otherwise we create a value-initialized (to 0) entry in the map and
try to use it later.

pdns/dnsdist-tcp.cc

index 2e01da518d513612f0833797764dcdeee22e5ba5..9d9f956872ece4168eb257e70316c0409025b670 100644 (file)
@@ -340,7 +340,8 @@ void* tcpClientThread(int pipefd)
 
        int dsock = -1;
        if(sockets.count(ds->remote) == 0) {
-         dsock=sockets[ds->remote]=setupTCPDownstream(ds);
+         dsock=setupTCPDownstream(ds);
+         sockets[ds->remote]=dsock;
        }
        else
          dsock=sockets[ds->remote];
@@ -369,7 +370,8 @@ void* tcpClientThread(int pipefd)
           close(dsock);
           dsock=-1;
           sockets.erase(ds->remote);
-          sockets[ds->remote]=dsock=setupTCPDownstream(ds);
+          dsock=setupTCPDownstream(ds);
+          sockets[ds->remote]=dsock;
           downstream_failures++;
           goto retry;
         }
@@ -387,7 +389,8 @@ void* tcpClientThread(int pipefd)
           close(dsock);
           dsock=-1;
           sockets.erase(ds->remote);
-          sockets[ds->remote]=dsock=setupTCPDownstream(ds);
+          dsock=setupTCPDownstream(ds);
+          sockets[ds->remote]=dsock;
           downstream_failures++;
           goto retry;
         }
@@ -405,7 +408,8 @@ void* tcpClientThread(int pipefd)
           close(dsock);
           dsock=-1;
           sockets.erase(ds->remote);
-          sockets[ds->remote]=dsock=setupTCPDownstream(ds);
+          dsock=setupTCPDownstream(ds);
+          sockets[ds->remote]=dsock;
           downstream_failures++;
           if(xfrStarted) {
             goto drop;