FreeBSD/contrib/ntp/libntp/ntp_intres.c
/*
 * should_retry_dns is a helper used by getaddrinfo_sometime_complete
 * and getnameinfo_sometime_complete which implements ntpd's DNS retry
 * policy.
 */
should_retry_dns is a helper used by getaddrinfo_sometime_complete
and getnameinfo_sometime_complete which implements ntpd's DNS retry
policy.
should_retry_dns is a helper used by getaddrinfo_sometime_complete and getnameinfo_sometime_complete which implements ntpd ' s DNS retry policy .
static int
should_retry_dns(
	int	rescode,
	int	res_errno
	)
{
	static int	eai_again_seen;
	int		again;
#if defined (EAI_SYSTEM) && defined(DEBUG)
	char		msg[256];
#endif
	again = 0;
	switch (rescode) {
	case EAI_FAIL:
		again = 1;
		break;
	case EAI_AGAIN:
		again = 1;
		eai_again_seen = 1;		
		break;
	case EAI_NONAME:
#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME)
	case EAI_NODATA:
#endif
		again = !eai_again_seen;	
		break;
#ifdef EAI_SYSTEM
	case EAI_SYSTEM:
		again = 1;
# ifdef DEBUG
		errno_to_str(res_errno, msg, sizeof(msg));
		TRACE(1, ("intres: EAI_SYSTEM errno %d (%s) means try again, right?\n",
			  res_errno, msg));
# endif
		break;
#endif
	}
	TRACE(2, ("intres: resolver returned: %s (%d), %sretrying\n",
		  gai_strerror(rescode), rescode, again ? "" : "not "));
	return again;
}
static int should_retry_dns ( int rescode , int res_errno ) { static int eai_again_seen ; int again ; #if defined ( EAI_SYSTEM ) && defined ( DEBUG ) char msg [ 256 ] ; #endif again = 0 ; switch ( rescode ) { case EAI_FAIL : again = 1 ; break ; case EAI_AGAIN : again = 1 ; eai_again_seen = 1 ; break ; case EAI_NONAME : #if defined ( EAI_NODATA ) && ( EAI_NODATA != EAI_NONAME ) case EAI_NODATA : #endif again = ! eai_again_seen ; break ; #ifdef EAI_SYSTEM case EAI_SYSTEM : again = 1 ; # ifdef DEBUG errno_to_str ( res_errno , msg , sizeof ( msg ) ) ; TRACE ( 1 , ( " \n " , res_errno , msg ) ) ; # endif break ; #endif } TRACE ( 2 , ( " \n " , gai_strerror ( rescode ) , rescode , again ? " " : " " ) ) ; return again ; }
should_retry_dns is a helper used by getaddrinfo_sometime_complete
 and getnameinfo_sometime_complete which implements ntpd's DNS retry
 policy.
should_retry_dns is a helper used by getaddrinfo_sometime_complete and getnameinfo_sometime_complete which implements ntpd ' s DNS retry policy .
/*
	 * If the resolver failed, see if the failure is
	 * temporary. If so, return success.
	 */ /* [Bug 1178] */ /* [Bug 1178] */ /* 
		 * EAI_SYSTEM means the real error is in errno.  We should be more
		 * discriminating about which errno values require retrying, but
		 * this matches existing behavior.
		 */