From ccb4b5e27541367826efd34d0feb3f6dfe442ca0 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 21 Jul 2016 16:49:20 +0200 Subject: [PATCH] save errno before we clobber it --- pdns/iputils.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pdns/iputils.cc b/pdns/iputils.cc index bc66780d3..1fe087244 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; } -- 2.40.0