@ -50,17 +50,17 @@
# include "ares_nameser.h"
# include "ares_dns.h"
static void timeadd ( struct timeval * now , size_t millisecs ) ;
static void timeadd ( ares_timeval_t * now , size_t millisecs ) ;
static ares_bool_t try_again ( int errnum ) ;
static void write_tcp_data ( ares_channel_t * channel , fd_set * write_fds ,
ares_socket_t write_fd ) ;
static void read_packets ( ares_channel_t * channel , fd_set * read_fds ,
ares_socket_t read_fd , struct timeval * now ) ;
static void process_timeouts ( ares_channel_t * channel , struct timeval * now ) ;
ares_socket_t read_fd , ares_timeval_t * now ) ;
static void process_timeouts ( ares_channel_t * channel , ares_timeval_t * now ) ;
static ares_status_t process_answer ( ares_channel_t * channel ,
const unsigned char * abuf , size_t alen ,
struct server_connection * conn ,
ares_bool_t tcp , struct timeval * now ) ;
ares_bool_t tcp , ares_timeval_t * now ) ;
static void handle_conn_error ( struct server_connection * conn ,
ares_bool_t critical_failure ) ;
@ -111,7 +111,7 @@ static void server_increment_failures(struct server_state *server,
{
ares__slist_node_t * node ;
const ares_channel_t * channel = server - > channel ;
struct timeval next_retry_time ;
ares_timeval_t next_retry_time ;
node = ares__slist_node_find ( channel - > servers , server ) ;
if ( node = = NULL ) {
@ -145,8 +145,8 @@ static void server_set_good(struct server_state *server, ares_bool_t used_tcp)
ares__slist_node_reinsert ( node ) ;
}
server - > next_retry_time . tv_ sec = 0 ;
server - > next_retry_time . tv_ usec = 0 ;
server - > next_retry_time . sec = 0 ;
server - > next_retry_time . usec = 0 ;
invoke_server_state_cb ( server , ARES_TRUE ,
used_tcp = = ARES_TRUE ? ARES_SERV_STATE_TCP
@ -154,10 +154,10 @@ static void server_set_good(struct server_state *server, ares_bool_t used_tcp)
}
/* return true if now is exactly check time or later */
ares_bool_t ares__timedout ( const struct timeval * now ,
const struct timeval * check )
ares_bool_t ares__timedout ( const ares_timeval_t * now ,
const ares_timeval_t * check )
{
ares_int64_t secs = ( ( ares_int64_t ) now - > tv_ sec - ( ares_int64_t ) check - > tv_ sec) ;
ares_int64_t secs = ( now - > sec - check - > sec ) ;
if ( secs > 0 ) {
return ARES_TRUE ; /* yes, timed out */
@ -167,20 +167,20 @@ ares_bool_t ares__timedout(const struct timeval *now,
}
/* if the full seconds were identical, check the sub second parts */
return ( ( ares_int64_t ) now - > tv_ usec - ( ares_int64_t ) check - > tv_ usec) > = 0
return ( ( ares_int64_t ) now - > usec - ( ares_int64_t ) check - > usec ) > = 0
? ARES_TRUE
: ARES_FALSE ;
}
/* add the specific number of milliseconds to the time in the first argument */
static void timeadd ( struct timeval * now , size_t millisecs )
static void timeadd ( ares_timeval_t * now , size_t millisecs )
{
now - > tv_ sec + = ( time _t) millisecs / 1000 ;
now - > tv_ usec + = ( time_ t) ( ( millisecs % 1000 ) * 1000 ) ;
now - > sec + = ( ares_int64 _t) millisecs / 1000 ;
now - > usec + = ( unsigned in t) ( ( millisecs % 1000 ) * 1000 ) ;
if ( now - > tv_ usec > = 1000000 ) {
+ + ( now - > tv_sec ) ;
now - > tv_usec - = 1000000 ;
if ( now - > usec > = 1000000 ) {
now - > sec + = now - > usec / 1000000 ;
now - > usec % = 1000000 ;
}
}
@ -191,7 +191,7 @@ static void processfds(ares_channel_t *channel, fd_set *read_fds,
ares_socket_t read_fd , fd_set * write_fds ,
ares_socket_t write_fd )
{
struct timeval now ;
ares_timeval_t now ;
if ( channel = = NULL ) {
return ;
@ -324,7 +324,7 @@ static void write_tcp_data(ares_channel_t *channel, fd_set *write_fds,
* a packet if we finish reading one .
*/
static void read_tcp_data ( ares_channel_t * channel ,
struct server_connection * conn , struct timeval * now )
struct server_connection * conn , ares_timeval_t * now )
{
ares_ssize_t count ;
struct server_state * server = conn - > server ;
@ -463,7 +463,7 @@ fail:
/* If any UDP sockets select true for reading, process them. */
static void read_udp_packets_fd ( ares_channel_t * channel ,
struct server_connection * conn ,
struct timeval * now )
ares_timeval_t * now )
{
ares_ssize_t read_len ;
unsigned char buf [ MAXENDSSZ + 1 ] ;
@ -527,7 +527,7 @@ static void read_udp_packets_fd(ares_channel_t *channel,
}
static void read_packets ( ares_channel_t * channel , fd_set * read_fds ,
ares_socket_t read_fd , struct timeval * now )
ares_socket_t read_fd , ares_timeval_t * now )
{
size_t i ;
ares_socket_t * socketlist = NULL ;
@ -594,7 +594,7 @@ static void read_packets(ares_channel_t *channel, fd_set *read_fds,
}
/* If any queries have timed out, note the timeout and move them on. */
static void process_timeouts ( ares_channel_t * channel , struct timeval * now )
static void process_timeouts ( ares_channel_t * channel , ares_timeval_t * now )
{
ares__slist_node_t * node =
ares__slist_node_first ( channel - > queries_by_timeout ) ;
@ -667,7 +667,7 @@ done:
static ares_status_t process_answer ( ares_channel_t * channel ,
const unsigned char * abuf , size_t alen ,
struct server_connection * conn ,
ares_bool_t tcp , struct timeval * now )
ares_bool_t tcp , ares_timeval_t * now )
{
struct query * query ;
/* Cache these as once ares__send_query() gets called, it may end up
@ -814,7 +814,7 @@ static void handle_conn_error(struct server_connection *conn,
ares__close_connection ( conn ) ;
}
ares_status_t ares__requeue_query ( struct query * query , struc t timeval * now )
ares_status_t ares__requeue_query ( struct query * query , con st ares_ timeval_t * now )
{
ares_channel_t * channel = query - > channel ;
size_t max_tries = ares__slist_len ( channel - > servers ) * channel - > tries ;
@ -912,7 +912,7 @@ static struct server_state *ares__failover_server(ares_channel_t *channel)
ares__rand_bytes ( channel - > rand_state , ( unsigned char * ) & r , sizeof ( r ) ) ;
if ( r % channel - > server_retry_chance = = 0 ) {
/* Select a suitable failed server to retry. */
struct timeval now = ares__tvnow ( ) ;
ares_timeval_t now = ares__tvnow ( ) ;
ares__slist_node_t * node ;
for ( node = ares__slist_node_first ( channel - > servers ) ; node ! = NULL ;
node = ares__slist_node_next ( node ) ) {
@ -989,7 +989,7 @@ static size_t ares__calc_query_timeout(const struct query *query)
return timeplus ;
}
ares_status_t ares__send_query ( struct query * query , struc t timeval * now )
ares_status_t ares__send_query ( struct query * query , con st ares_ timeval_t * now )
{
ares_channel_t * channel = query - > channel ;
struct server_state * server ;