]> granicus.if.org Git - pdns/commitdiff
save errno before we clobber it
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 21 Jul 2016 14:49:20 +0000 (16:49 +0200)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 21 Jul 2016 14:49:20 +0000 (16:49 +0200)
pdns/iputils.cc

index bc66780d3d3d799e6fcf9526cea38e5620cc9a92..1fe0872449a30fea41a54b8cce1d031895e82afe 100644 (file)
@@ -23,16 +23,20 @@ int SSocket(int family, int type, int flags)
 int SConnect(int sockfd, const ComboAddress& remote)
 {
   int ret = connect(sockfd, (struct sockaddr*)&remote, remote.getSocklen());
-  if(ret < 0)
-    RuntimeError(boost::format("connecting socket to %s: %s") % remote.toStringWithPort() % strerror(errno));
+  if(ret < 0) {
+    int savederrno = errno;
+    RuntimeError(boost::format("connecting socket to %s: %s") % remote.toStringWithPort() % strerror(savederrno));
+  }
   return ret;
 }
 
 int SBind(int sockfd, const ComboAddress& local)
 {
   int ret = bind(sockfd, (struct sockaddr*)&local, local.getSocklen());
-  if(ret < 0)
-    RuntimeError(boost::format("binding socket to %s: %s") % local.toStringWithPort() % strerror(errno));
+  if(ret < 0) {
+    int savederrno = errno;
+    RuntimeError(boost::format("binding socket to %s: %s") % local.toStringWithPort() % strerror(savederrno));
+  }
   return ret;
 }