mirror of https://github.com/getdnsapi/getdns.git
working prototype 6
This commit is contained in:
parent
f5662bbf32
commit
51eb2fdf55
|
@ -981,6 +981,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent,
|
|||
if (!json &&
|
||||
(strcmp(item->node.key, "type") == 0 ||
|
||||
strcmp(item->node.key, "type_covered") == 0 ||
|
||||
strcmp(item->node.key, "query_type") == 0 ||
|
||||
strcmp(item->node.key, "qtype") == 0) &&
|
||||
(strval = _getdns_rr_type_name(item->i.data.n))) {
|
||||
if (gldns_buffer_printf(
|
||||
|
|
26
src/stub.c
26
src/stub.c
|
@ -1176,6 +1176,19 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
|
|||
return STUB_TCP_ERROR;
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
_getdns_get_time_as_uintt64() {
|
||||
|
||||
struct timeval tv;
|
||||
uint64_t now;
|
||||
|
||||
if (gettimeofday(&tv, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
now = tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
return now;
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/* UDP callback functions */
|
||||
/**************************/
|
||||
|
@ -1237,6 +1250,7 @@ stub_udp_read_cb(void *userarg)
|
|||
netreq->response_len = read;
|
||||
dnsreq->upstreams->current = 0;
|
||||
done:
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
_getdns_check_dns_req_complete(dnsreq);
|
||||
}
|
||||
|
@ -1251,6 +1265,7 @@ stub_udp_write_cb(void *userarg)
|
|||
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
||||
netreq->debug_start_time = _getdns_get_time_as_uintt64();
|
||||
netreq->query_id = arc4random();
|
||||
GLDNS_ID_SET(netreq->query, netreq->query_id);
|
||||
if (netreq->opt) {
|
||||
|
@ -1314,7 +1329,7 @@ stub_tcp_read_cb(void *userarg)
|
|||
netreq->tcp.read_pos - netreq->tcp.read_buf;
|
||||
netreq->tcp.read_buf = NULL;
|
||||
dnsreq->upstreams->current = 0;
|
||||
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
stub_cleanup(netreq);
|
||||
close(netreq->fd);
|
||||
_getdns_check_dns_req_complete(dnsreq);
|
||||
|
@ -1327,7 +1342,7 @@ stub_tcp_write_cb(void *userarg)
|
|||
getdns_network_req *netreq = (getdns_network_req *)userarg;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
int q;
|
||||
|
||||
netreq->debug_start_time = _getdns_get_time_as_uintt64();
|
||||
switch ((q = stub_tcp_write(netreq->fd, &netreq->tcp, netreq))) {
|
||||
case STUB_TCP_AGAIN:
|
||||
return;
|
||||
|
@ -1420,7 +1435,7 @@ upstream_read_cb(void *userarg)
|
|||
getdns_eventloop_event_init(&upstream->event, upstream,
|
||||
NULL, upstream_write_cb, NULL));
|
||||
}
|
||||
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
/* This also reschedules events for the upstream*/
|
||||
stub_cleanup(netreq);
|
||||
|
||||
|
@ -1447,7 +1462,10 @@ upstream_write_cb(void *userarg)
|
|||
getdns_network_req *netreq = upstream->write_queue;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
int q;
|
||||
|
||||
|
||||
/* TODO: think about TCP AGAIN */
|
||||
netreq->debug_start_time = _getdns_get_time_as_uintt64();
|
||||
|
||||
DEBUG_STUB("--- WRITE: %s: %p TYPE: %d\n", __FUNCTION__, netreq,
|
||||
netreq->request_type);
|
||||
if (tls_requested(netreq) && tls_should_write(upstream))
|
||||
|
|
|
@ -724,13 +724,10 @@ _getdns_create_call_debugging_dict(getdns_context *context,
|
|||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int(netreq_debug, "start_time",
|
||||
netreq->debug_start_time)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int(netreq_debug, "end_time",
|
||||
netreq->debug_end_time)) {
|
||||
|
||||
/* TODO: This is not safe */
|
||||
uint32_t run_time = (uint32_t)(netreq->debug_end_time - netreq->debug_start_time);
|
||||
if (getdns_dict_set_int(netreq_debug, "run_time/ms", run_time/1000)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue