Return call_reporting info in case of timeout, so that we can see

which server did not respond.
This commit is contained in:
Robert Groenenberg 2016-06-20 18:39:15 +02:00
parent 6d63f74d18
commit 3634fff4dd
3 changed files with 26 additions and 3 deletions

View File

@ -91,6 +91,7 @@ static int upstream_connect(getdns_upstream *upstream,
static int fallback_on_write(getdns_network_req *netreq);
static void stub_timeout_cb(void *userarg);
static uint64_t _getdns_get_time_as_uintt64()
/*****************************/
/* General utility functions */
/*****************************/
@ -564,9 +565,11 @@ stub_timeout_cb(void *userarg)
stub_next_upstream(netreq);
stub_cleanup(netreq);
if (netreq->fd >= 0) close(netreq->fd);
if (netreq->owner->user_callback)
if (netreq->owner->user_callback) {
netreq->state = NET_REQ_TIMED_OUT;
netreq->debug_end_time = _getdns_get_time_as_uintt64();
(void) _getdns_context_request_timed_out(netreq->owner);
else {
} else {
netreq->state = NET_REQ_FINISHED;
_getdns_check_dns_req_complete(netreq->owner);
}

View File

@ -157,7 +157,8 @@ typedef enum network_req_state_enum
NET_REQ_NOT_SENT,
NET_REQ_IN_FLIGHT,
NET_REQ_FINISHED,
NET_REQ_CANCELED
NET_REQ_CANCELED,
NET_REQ_TIMED_OUT
} network_req_state;

View File

@ -1189,6 +1189,25 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
netreq->response_len, netreq->response))
goto error;
}
if (!nreplies && call_reporting) {
for ( netreq_p = completed_request->netreqs
; (netreq = *netreq_p) ; netreq_p++) {
/* Add call_reporting info for timed out request */
if (netreq->state == NET_REQ_TIMED_OUT) {
if (!(netreq_debug =
_getdns_create_call_reporting_dict(context,netreq)))
goto error;
if (_getdns_list_append_this_dict(
call_reporting, netreq_debug)) {
getdns_dict_destroy(netreq_debug);
goto error;
}
}
}
}
if (_getdns_dict_set_this_list(result, "replies_tree", replies_tree))
goto error;
replies_tree = NULL;