mirror of https://github.com/getdnsapi/getdns.git
uniform debugging method + disable stub debugging
This commit is contained in:
parent
011b504496
commit
98b3364b65
29
src/stub.c
29
src/stub.c
|
@ -51,8 +51,6 @@
|
||||||
/* Don't currently have access to the context whilst doing handshake */
|
/* Don't currently have access to the context whilst doing handshake */
|
||||||
#define TIMEOUT_TLS 2500
|
#define TIMEOUT_TLS 2500
|
||||||
|
|
||||||
#define STUB_DEBUG 0
|
|
||||||
|
|
||||||
static time_t secret_rollover_time = 0;
|
static time_t secret_rollover_time = 0;
|
||||||
static uint32_t secret = 0;
|
static uint32_t secret = 0;
|
||||||
static uint32_t prev_secret = 0;
|
static uint32_t prev_secret = 0;
|
||||||
|
@ -71,13 +69,6 @@ static void stub_tcp_write_cb(void *userarg);
|
||||||
/* General utility functions */
|
/* General utility functions */
|
||||||
/*****************************/
|
/*****************************/
|
||||||
|
|
||||||
static void
|
|
||||||
stub_debug(const char *function_name)
|
|
||||||
{
|
|
||||||
#ifdef STUB_DEBUG
|
|
||||||
fprintf(stderr,"[STUB DEBUG]: %s\n", function_name);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rollover_secret()
|
rollover_secret()
|
||||||
|
@ -550,7 +541,7 @@ stub_timeout_cb(void *userarg)
|
||||||
static void
|
static void
|
||||||
upstream_tls_timeout_cb(void *userarg)
|
upstream_tls_timeout_cb(void *userarg)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
||||||
/* Clean up and trigger a write to let the fallback code to its job */
|
/* Clean up and trigger a write to let the fallback code to its job */
|
||||||
tls_cleanup(upstream);
|
tls_cleanup(upstream);
|
||||||
|
@ -819,7 +810,7 @@ tls_create_object(getdns_context *context, int fd)
|
||||||
static int
|
static int
|
||||||
tls_do_handshake(getdns_upstream *upstream)
|
tls_do_handshake(getdns_upstream *upstream)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
int r;
|
int r;
|
||||||
int want;
|
int want;
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
|
@ -1208,7 +1199,7 @@ stub_tcp_write_cb(void *userarg)
|
||||||
static void
|
static void
|
||||||
upstream_read_cb(void *userarg)
|
upstream_read_cb(void *userarg)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
||||||
getdns_network_req *netreq;
|
getdns_network_req *netreq;
|
||||||
getdns_dns_req *dnsreq;
|
getdns_dns_req *dnsreq;
|
||||||
|
@ -1319,7 +1310,7 @@ netreq_upstream_read_cb(void *userarg)
|
||||||
static void
|
static void
|
||||||
upstream_write_cb(void *userarg)
|
upstream_write_cb(void *userarg)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
||||||
getdns_network_req *netreq = upstream->write_queue;
|
getdns_network_req *netreq = upstream->write_queue;
|
||||||
getdns_dns_req *dnsreq = netreq->owner;
|
getdns_dns_req *dnsreq = netreq->owner;
|
||||||
|
@ -1466,7 +1457,7 @@ int
|
||||||
upstream_connect(getdns_upstream *upstream, getdns_base_transport_t transport,
|
upstream_connect(getdns_upstream *upstream, getdns_base_transport_t transport,
|
||||||
getdns_dns_req *dnsreq)
|
getdns_dns_req *dnsreq)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
switch(transport) {
|
switch(transport) {
|
||||||
case GETDNS_BASE_TRANSPORT_UDP:
|
case GETDNS_BASE_TRANSPORT_UDP:
|
||||||
|
@ -1570,7 +1561,7 @@ static int
|
||||||
move_netreq(getdns_network_req *netreq, getdns_upstream *upstream,
|
move_netreq(getdns_network_req *netreq, getdns_upstream *upstream,
|
||||||
getdns_upstream *new_upstream)
|
getdns_upstream *new_upstream)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
/* Remove from queue, clearing event and fd if we are the last*/
|
/* Remove from queue, clearing event and fd if we are the last*/
|
||||||
if (!(upstream->write_queue = netreq->write_queue_tail)) {
|
if (!(upstream->write_queue = netreq->write_queue_tail)) {
|
||||||
upstream->write_queue_last = NULL;
|
upstream->write_queue_last = NULL;
|
||||||
|
@ -1626,7 +1617,7 @@ move_netreq(getdns_network_req *netreq, getdns_upstream *upstream,
|
||||||
static int
|
static int
|
||||||
fallback_on_write(getdns_network_req *netreq)
|
fallback_on_write(getdns_network_req *netreq)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
/* TODO[TLS]: Fallback through all transports.*/
|
/* TODO[TLS]: Fallback through all transports.*/
|
||||||
getdns_base_transport_t next_transport =
|
getdns_base_transport_t next_transport =
|
||||||
netreq->dns_base_transports[netreq->transport + 1];
|
netreq->dns_base_transports[netreq->transport + 1];
|
||||||
|
@ -1652,7 +1643,7 @@ fallback_on_write(getdns_network_req *netreq)
|
||||||
static void
|
static void
|
||||||
upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
|
upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
/* We have a connected socket and a global event loop */
|
/* We have a connected socket and a global event loop */
|
||||||
assert(upstream->fd >= 0);
|
assert(upstream->fd >= 0);
|
||||||
assert(upstream->loop);
|
assert(upstream->loop);
|
||||||
|
@ -1685,7 +1676,7 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
||||||
{
|
{
|
||||||
stub_debug(__FUNCTION__);
|
DEBUG_STUB("%s\n", __FUNCTION__);
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
getdns_dns_req *dnsreq = netreq->owner;
|
getdns_dns_req *dnsreq = netreq->owner;
|
||||||
|
|
||||||
|
@ -1725,4 +1716,4 @@ priv_getdns_submit_stub_request(getdns_network_req *netreq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stub.c */
|
/* stub.c */
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
#define SCHED_DEBUG 0
|
#define SCHED_DEBUG 0
|
||||||
#define WIRE_DEBUG 0
|
#define WIRE_DEBUG 0
|
||||||
|
#define STUB_DEBUG 0
|
||||||
|
|
||||||
#ifdef S_SPLINT_S
|
#ifdef S_SPLINT_S
|
||||||
# define INLINE
|
# define INLINE
|
||||||
|
@ -173,6 +174,13 @@ create_list_from_rr_list(struct getdns_context *context, ldns_rr_list * rr_list)
|
||||||
#define DEBUG_SCHED(...) DEBUG_OFF(__VA_ARGS__)
|
#define DEBUG_SCHED(...) DEBUG_OFF(__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(STUB_DEBUG) && STUB_DEBUG
|
||||||
|
#include <time.h>
|
||||||
|
#define DEBUG_STUB(...) DEBUG_ON(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
INLINE getdns_eventloop_event *getdns_eventloop_event_init(
|
INLINE getdns_eventloop_event *getdns_eventloop_event_init(
|
||||||
getdns_eventloop_event *ev,void *userarg, getdns_eventloop_callback read_cb,
|
getdns_eventloop_event *ev,void *userarg, getdns_eventloop_callback read_cb,
|
||||||
getdns_eventloop_callback write_cb, getdns_eventloop_callback timeout_cb)
|
getdns_eventloop_callback write_cb, getdns_eventloop_callback timeout_cb)
|
||||||
|
|
Loading…
Reference in New Issue