From: Peter van Dijk Date: Thu, 21 Jul 2016 14:49:20 +0000 (+0200) Subject: save errno before we clobber it X-Git-Tag: auth-4.0.1~25^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4221%2Fhead;p=thirdparty%2Fpdns.git save errno before we clobber it --- diff --git a/pdns/iputils.cc b/pdns/iputils.cc index bc66780d3d..1fe0872449 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -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; }