From 294c82a983caa0fa13808bee81d8684c9c5c944a Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 6 Nov 2007 21:14:30 +0000 Subject: [PATCH] WTF? Two csocket updates on one day? Fix the wrong error message for gethostbyname() and in case of a real error use the proper error message. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@865 726aef4b-f618-498e-8847-2d620e286838 --- Csocket.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Csocket.cpp b/Csocket.cpp index 3e130a40..5b66a838 100644 --- a/Csocket.cpp +++ b/Csocket.cpp @@ -28,7 +28,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * -* $Revision: 1.59 $ +* $Revision: 1.60 $ */ #include "Csocket.h" @@ -87,18 +87,32 @@ static int __GetHostByName( const CS_STRING & sHostName, struct in_addr *paddr, break; if ( iReturn != TRY_AGAIN ) + { + CS_DEBUG( "gethostyname_r: " << hstrerror( h_errno ) ); break; + } - PERROR( "gethostbyname_r" ); } if ( ( !hent ) && ( iReturn == 0 ) ) iReturn = HOST_NOT_FOUND; #else - hent = gethostbyname( sHostName.c_str() ); - PERROR( "gethostbyname" ); + for( u_int a = 0; a < iNumRetries; a++ ) + { + iReturn = HOST_NOT_FOUND; + hent = gethostbyname( sHostName.c_str() ); - if ( hent ) - iReturn = 0; + if ( hent ) + { + iReturn = 0; + break; + } + + if( h_errno != TRY_AGAIN ) + { + CS_DEBUG( "gethostyname: " << hstrerror( h_errno ) ); + break; + } + } #endif /* __linux__ */