mirror of https://github.com/getdnsapi/getdns.git
Merge pull request #187 from rwgroenenberg/call_reporting_timeout
Return call_reporting info in case of timeout, so that we can see which server did not respond.
This commit is contained in:
commit
b56fbbb604
12
src/dnssec.c
12
src/dnssec.c
|
@ -2776,19 +2776,13 @@ static size_t count_outstanding_requests(chain_head *head)
|
||||||
|
|
||||||
count += node->lock;
|
count += node->lock;
|
||||||
|
|
||||||
if (node->dnskey_req &&
|
if (!_getdns_netreq_finished(node->dnskey_req))
|
||||||
node->dnskey_req->state != NET_REQ_FINISHED &&
|
|
||||||
node->dnskey_req->state != NET_REQ_CANCELED)
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (node->ds_req &&
|
if (!_getdns_netreq_finished(node->ds_req))
|
||||||
node->ds_req->state != NET_REQ_FINISHED &&
|
|
||||||
node->ds_req->state != NET_REQ_CANCELED)
|
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (node->soa_req &&
|
if (!_getdns_netreq_finished(node->soa_req))
|
||||||
node->soa_req->state != NET_REQ_FINISHED &&
|
|
||||||
node->soa_req->state != NET_REQ_CANCELED)
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count + count_outstanding_requests(head->next);
|
return count + count_outstanding_requests(head->next);
|
||||||
|
|
|
@ -104,8 +104,7 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
|
||||||
int results_found = 0, r;
|
int results_found = 0, r;
|
||||||
|
|
||||||
for (netreq_p = dns_req->netreqs; (netreq = *netreq_p); netreq_p++)
|
for (netreq_p = dns_req->netreqs; (netreq = *netreq_p); netreq_p++)
|
||||||
if (netreq->state != NET_REQ_FINISHED &&
|
if (!_getdns_netreq_finished(netreq))
|
||||||
netreq->state != NET_REQ_CANCELED)
|
|
||||||
return;
|
return;
|
||||||
else if (netreq->response_len > 0)
|
else if (netreq->response_len > 0)
|
||||||
results_found = 1;
|
results_found = 1;
|
||||||
|
|
|
@ -91,6 +91,7 @@ static int upstream_connect(getdns_upstream *upstream,
|
||||||
static int fallback_on_write(getdns_network_req *netreq);
|
static int fallback_on_write(getdns_network_req *netreq);
|
||||||
|
|
||||||
static void stub_timeout_cb(void *userarg);
|
static void stub_timeout_cb(void *userarg);
|
||||||
|
static uint64_t _getdns_get_time_as_uintt64();
|
||||||
/*****************************/
|
/*****************************/
|
||||||
/* General utility functions */
|
/* General utility functions */
|
||||||
/*****************************/
|
/*****************************/
|
||||||
|
@ -564,12 +565,12 @@ stub_timeout_cb(void *userarg)
|
||||||
stub_next_upstream(netreq);
|
stub_next_upstream(netreq);
|
||||||
stub_cleanup(netreq);
|
stub_cleanup(netreq);
|
||||||
if (netreq->fd >= 0) close(netreq->fd);
|
if (netreq->fd >= 0) close(netreq->fd);
|
||||||
if (netreq->owner->user_callback)
|
netreq->state = NET_REQ_TIMED_OUT;
|
||||||
|
if (netreq->owner->user_callback) {
|
||||||
|
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||||
(void) _getdns_context_request_timed_out(netreq->owner);
|
(void) _getdns_context_request_timed_out(netreq->owner);
|
||||||
else {
|
} else
|
||||||
netreq->state = NET_REQ_FINISHED;
|
|
||||||
_getdns_check_dns_req_complete(netreq->owner);
|
_getdns_check_dns_req_complete(netreq->owner);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,10 +154,12 @@ priv_getdns_context_mf(getdns_context *context);
|
||||||
|
|
||||||
typedef enum network_req_state_enum
|
typedef enum network_req_state_enum
|
||||||
{
|
{
|
||||||
NET_REQ_NOT_SENT,
|
NET_REQ_NOT_SENT = 0,
|
||||||
NET_REQ_IN_FLIGHT,
|
NET_REQ_IN_FLIGHT = 1,
|
||||||
NET_REQ_FINISHED,
|
NET_REQ_FINISHED = 2, /* Finish type in bits 2 and 3 */
|
||||||
NET_REQ_CANCELED
|
NET_REQ_CANCELED = 6, /* 2 + (1 << 2) */
|
||||||
|
NET_REQ_TIMED_OUT = 10, /* 2 + (2 << 2) */
|
||||||
|
NET_REQ_ERRORED = 14 /* 2 + (3 << 2) */
|
||||||
} network_req_state;
|
} network_req_state;
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,11 +257,12 @@ typedef struct getdns_network_req
|
||||||
uint8_t *response;
|
uint8_t *response;
|
||||||
size_t wire_data_sz;
|
size_t wire_data_sz;
|
||||||
uint8_t wire_data[];
|
uint8_t wire_data[];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} getdns_network_req;
|
} getdns_network_req;
|
||||||
|
|
||||||
|
static inline int _getdns_netreq_finished(getdns_network_req *req)
|
||||||
|
{ return !req || (req->state & NET_REQ_FINISHED); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dns request - manages a number of network requests and
|
* dns request - manages a number of network requests and
|
||||||
* the initial data passed to getdns_general
|
* the initial data passed to getdns_general
|
||||||
|
|
|
@ -1109,6 +1109,18 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
||||||
for ( netreq_p = completed_request->netreqs
|
for ( netreq_p = completed_request->netreqs
|
||||||
; (netreq = *netreq_p) ; netreq_p++) {
|
; (netreq = *netreq_p) ; netreq_p++) {
|
||||||
|
|
||||||
|
if (call_reporting && ( netreq->response_len
|
||||||
|
|| 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))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
netreq_debug = NULL;
|
||||||
|
}
|
||||||
if (! netreq->response_len)
|
if (! netreq->response_len)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1171,20 +1183,6 @@ _getdns_create_getdns_response(getdns_dns_req *completed_request)
|
||||||
getdns_dict_destroy(reply);
|
getdns_dict_destroy(reply);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call_reporting) {
|
|
||||||
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_list_append_const_bindata(replies_full,
|
if (_getdns_list_append_const_bindata(replies_full,
|
||||||
netreq->response_len, netreq->response))
|
netreq->response_len, netreq->response))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue