From: Remi Gacogne Date: Tue, 5 Mar 2019 10:49:24 +0000 (+0100) Subject: Return EINPROGRESS instead of -1 in SConnectWithTimeout wo/ timeout X-Git-Tag: dnsdist-1.4.0-alpha1~25^2~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdf8277d2426e454e69f8be91adfa4266ce6f1fd;p=thirdparty%2Fpdns.git Return EINPROGRESS instead of -1 in SConnectWithTimeout wo/ timeout --- diff --git a/pdns/iputils.cc b/pdns/iputils.cc index daf5997d6f..0d7c342b00 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -47,7 +47,7 @@ int SSocket(int family, int type, int flags) int SConnect(int sockfd, const ComboAddress& remote) { - int ret = connect(sockfd, (struct sockaddr*)&remote, remote.getSocklen()); + int ret = connect(sockfd, reinterpret_cast(&remote), remote.getSocklen()); if(ret < 0) { int savederrno = errno; RuntimeError(boost::format("connecting socket to %s: %s") % remote.toStringWithPort() % strerror(savederrno)); @@ -57,12 +57,12 @@ int SConnect(int sockfd, const ComboAddress& remote) int SConnectWithTimeout(int sockfd, const ComboAddress& remote, int timeout) { - int ret = connect(sockfd, (struct sockaddr*)&remote, remote.getSocklen()); + int ret = connect(sockfd, reinterpret_cast(&remote), remote.getSocklen()); if(ret < 0) { int savederrno = errno; if (savederrno == EINPROGRESS) { if (timeout <= 0) { - return ret; + return savederrno; } /* we wait until the connection has been established */ @@ -97,7 +97,7 @@ int SConnectWithTimeout(int sockfd, const ComboAddress& remote, int timeout) } } - return ret; + return 0; } int SBind(int sockfd, const ComboAddress& local)