Use __func__ var when supported

And let debugging messages compile with -Wpedantic -Werror too
This commit is contained in:
Willem Toorop 2016-12-12 13:55:10 +01:00
parent 4518a3d672
commit 5f6b93f7f2
14 changed files with 100 additions and 154 deletions

View File

@ -945,6 +945,14 @@ fi
#---- check for pthreads library #---- check for pthreads library
AC_SEARCH_LIBS([pthread_mutex_init],[pthread],[AC_DEFINE([HAVE_PTHREADS], [1], [Have pthreads library])], [AC_MSG_WARN([pthreads not available])]) AC_SEARCH_LIBS([pthread_mutex_init],[pthread],[AC_DEFINE([HAVE_PTHREADS], [1], [Have pthreads library])], [AC_MSG_WARN([pthreads not available])])
AC_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable])
AC_LANG_PUSH(C)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[char*s=__func__;]],[[]])],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE___FUNC__, [1], [Whether the C compiler support the __func__ variable])],
[AC_MSG_RESULT([no])])
AC_LANG_POP(C)
dnl ----- dnl -----
dnl ----- Start of "Things needed for gldns" section dnl ----- Start of "Things needed for gldns" section
@ -1061,6 +1069,12 @@ AC_DEFINE_UNQUOTED([MAX_CNAME_REFERRALS], [100], [The maximum number of cname re
AH_BOTTOM([ AH_BOTTOM([
#ifdef HAVE___FUNC__
#define __FUNC__ __func__
#else
#define __FUNC__ __FUNCTION__
#endif
#ifdef GETDNS_ON_WINDOWS #ifdef GETDNS_ON_WINDOWS
/* On windows it is allowed to increase the FD_SETSIZE /* On windows it is allowed to increase the FD_SETSIZE
* (and nescessary to make our custom eventloop work) * (and nescessary to make our custom eventloop work)

View File

@ -152,7 +152,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
HCERTSTORE hSystemStore; HCERTSTORE hSystemStore;
PCCERT_CONTEXT pTargetCert = NULL; PCCERT_CONTEXT pTargetCert = NULL;
DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Adding Windows certificates to CA store"); "Adding Windows certificates to CA store");
/* load just once per context lifetime for this version of getdns /* load just once per context lifetime for this version of getdns
@ -181,7 +181,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
/* failure if the CA store is empty or the call fails */ /* failure if the CA store is empty or the call fails */
if ((pTargetCert = CertEnumCertificatesInStore( if ((pTargetCert = CertEnumCertificatesInStore(
hSystemStore, pTargetCert)) == 0) { hSystemStore, pTargetCert)) == 0) {
DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"CA certificate store for Windows is empty."); "CA certificate store for Windows is empty.");
return 0; return 0;
} }
@ -193,7 +193,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
pTargetCert->cbCertEncoded); pTargetCert->cbCertEncoded);
if (!cert1) { if (!cert1) {
/* return error if a cert fails */ /* return error if a cert fails */
DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Unable to parse certificate in memory", "Unable to parse certificate in memory",
ERR_get_error(), ERR_error_string(ERR_get_error(), NULL)); ERR_get_error(), ERR_error_string(ERR_get_error(), NULL));
return 0; return 0;
@ -201,7 +201,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
else { else {
/* return error if a cert add to store fails */ /* return error if a cert add to store fails */
if (X509_STORE_add_cert(store, cert1) == 0) { if (X509_STORE_add_cert(store, cert1) == 0) {
DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Error adding certificate", ERR_get_error(), "Error adding certificate", ERR_get_error(),
ERR_error_string(ERR_get_error(), NULL)); ERR_error_string(ERR_get_error(), NULL));
return 0; return 0;
@ -1525,7 +1525,7 @@ getdns_context_request_count_changed(getdns_context *context)
if (context->outbound_requests.count && ! context->ub_event.ev){ if (context->outbound_requests.count && ! context->ub_event.ev){
DEBUG_SCHED("gc_request_count_changed " DEBUG_SCHED("gc_request_count_changed "
"-> ub schedule(el_ev = %p, el_ev->ev = %p)\n", "-> ub schedule(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev); (void *)&context->ub_event, (void *)context->ub_event.ev);
#ifndef USE_WINSOCK #ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API #ifdef HAVE_UNBOUND_EVENT_API
if (!_getdns_ub_loop_enabled(&context->ub_loop)) if (!_getdns_ub_loop_enabled(&context->ub_loop))
@ -1539,7 +1539,7 @@ getdns_context_request_count_changed(getdns_context *context)
context->ub_event.ev) { context->ub_event.ev) {
DEBUG_SCHED("gc_request_count_changed " DEBUG_SCHED("gc_request_count_changed "
"-> ub clear(el_ev = %p, el_ev->ev = %p)\n", "-> ub clear(el_ev = %p, el_ev->ev = %p)\n",
&context->ub_event, context->ub_event.ev); (void *)&context->ub_event, (void *)context->ub_event.ev);
#ifndef USE_WINSOCK #ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API #ifdef HAVE_UNBOUND_EVENT_API

View File

@ -54,7 +54,7 @@ default_eventloop_schedule(getdns_eventloop *loop,
size_t i; size_t i;
DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p, FD_SETSIZE: %d)\n" DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p, FD_SETSIZE: %d)\n"
, __FUNCTION__, loop, fd, timeout, event, FD_SETSIZE); , __FUNC__, (void *)loop, fd, timeout, (void *)event, FD_SETSIZE);
if (!loop || !event) if (!loop || !event)
return GETDNS_RETURN_INVALID_PARAMETER; return GETDNS_RETURN_INVALID_PARAMETER;
@ -75,11 +75,11 @@ default_eventloop_schedule(getdns_eventloop *loop,
if (default_loop->fd_events[fd] == event) { if (default_loop->fd_events[fd] == event) {
DEBUG_SCHED("WARNING: Event %p not cleared " DEBUG_SCHED("WARNING: Event %p not cleared "
"before being rescheduled!\n" "before being rescheduled!\n"
, default_loop->fd_events[fd]); , (void *)default_loop->fd_events[fd]);
} else { } else {
DEBUG_SCHED("ERROR: A different event is " DEBUG_SCHED("ERROR: A different event is "
"already present at fd slot: %p!\n" "already present at fd slot: %p!\n"
, default_loop->fd_events[fd]); , (void *)default_loop->fd_events[fd]);
} }
} }
#endif #endif
@ -123,7 +123,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
if (!loop || !event) if (!loop || !event)
return GETDNS_RETURN_INVALID_PARAMETER; return GETDNS_RETURN_INVALID_PARAMETER;
DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNCTION__, loop, event); DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNC__, (void *)loop, (void *)event);
i = (intptr_t)event->ev - 1; i = (intptr_t)event->ev - 1;
if (i < 0 || i >= FD_SETSIZE) { if (i < 0 || i >= FD_SETSIZE) {
@ -134,7 +134,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
if (default_loop->timeout_events[i] != event) if (default_loop->timeout_events[i] != event)
DEBUG_SCHED( "ERROR: Different/wrong event present at " DEBUG_SCHED( "ERROR: Different/wrong event present at "
"timeout slot: %p!\n" "timeout slot: %p!\n"
, default_loop->timeout_events[i]); , (void *)default_loop->timeout_events[i]);
#endif #endif
default_loop->timeout_events[i] = NULL; default_loop->timeout_events[i] = NULL;
} else { } else {
@ -142,7 +142,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
if (default_loop->fd_events[i] != event) if (default_loop->fd_events[i] != event)
DEBUG_SCHED( "ERROR: Different/wrong event present at " DEBUG_SCHED( "ERROR: Different/wrong event present at "
"fd slot: %p!\n" "fd slot: %p!\n"
, default_loop->fd_events[i]); , (void *)default_loop->fd_events[i]);
#endif #endif
default_loop->fd_events[i] = NULL; default_loop->fd_events[i] = NULL;
} }
@ -162,7 +162,7 @@ default_read_cb(int fd, getdns_eventloop_event *event)
#if !defined(SCHED_DEBUG) || !SCHED_DEBUG #if !defined(SCHED_DEBUG) || !SCHED_DEBUG
(void)fd; (void)fd;
#endif #endif
DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->read_cb(event->userarg); event->read_cb(event->userarg);
} }
@ -172,7 +172,7 @@ default_write_cb(int fd, getdns_eventloop_event *event)
#if !defined(SCHED_DEBUG) || !SCHED_DEBUG #if !defined(SCHED_DEBUG) || !SCHED_DEBUG
(void)fd; (void)fd;
#endif #endif
DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->write_cb(event->userarg); event->write_cb(event->userarg);
} }
@ -182,7 +182,7 @@ default_timeout_cb(int fd, getdns_eventloop_event *event)
#if !defined(SCHED_DEBUG) || !SCHED_DEBUG #if !defined(SCHED_DEBUG) || !SCHED_DEBUG
(void)fd; (void)fd;
#endif #endif
DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->timeout_cb(event->userarg); event->timeout_cb(event->userarg);
} }

View File

@ -419,7 +419,7 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
x = sk_X509_value(X509_STORE_CTX_get0_untrusted(store), i); x = sk_X509_value(X509_STORE_CTX_get0_untrusted(store), i);
#if defined(STUB_DEBUG) && STUB_DEBUG #if defined(STUB_DEBUG) && STUB_DEBUG
DEBUG_STUB("%s %-35s: Name of cert: %d ", DEBUG_STUB("%s %-35s: Name of cert: %d ",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, i); STUB_DEBUG_SETUP_TLS, __FUNC__, i);
X509_NAME_print_ex_fp(stderr, X509_get_subject_name(x), 1, XN_FLAG_ONELINE); X509_NAME_print_ex_fp(stderr, X509_get_subject_name(x), 1, XN_FLAG_ONELINE);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
#endif #endif
@ -427,13 +427,13 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), NULL); len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), NULL);
if (len > (int)sizeof(raw)) { if (len > (int)sizeof(raw)) {
DEBUG_STUB("%s %-35s: Pubkey %d is larger than "PRIsz" octets\n", DEBUG_STUB("%s %-35s: Pubkey %d is larger than "PRIsz" octets\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, sizeof(raw)); STUB_DEBUG_SETUP_TLS, __FUNC__, i, sizeof(raw));
continue; continue;
} }
i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &next); i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &next);
if (next - raw != len) { if (next - raw != len) {
DEBUG_STUB("%s %-35s: Pubkey %d claimed it needed %d octets, really needed "PRIsz"\n", DEBUG_STUB("%s %-35s: Pubkey %d claimed it needed %d octets, really needed "PRIsz"\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, len, next - raw); STUB_DEBUG_SETUP_TLS, __FUNC__, i, len, next - raw);
continue; continue;
} }
SHA256(raw, len, buf); SHA256(raw, len, buf);
@ -442,11 +442,11 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
for (p = pinset; p; p = p->next) for (p = pinset; p; p = p->next)
if (0 == memcmp(buf, p->pin, sizeof(p->pin))) { if (0 == memcmp(buf, p->pin, sizeof(p->pin))) {
DEBUG_STUB("%s %-35s: Pubkey %d matched pin %p ("PRIsz")\n", DEBUG_STUB("%s %-35s: Pubkey %d matched pin %p ("PRIsz")\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, p, sizeof(p->pin)); STUB_DEBUG_SETUP_TLS, __FUNC__, i, (void *)p, sizeof(p->pin));
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;
} else } else
DEBUG_STUB("%s %-35s: Pubkey %d did not match pin %p\n", DEBUG_STUB("%s %-35s: Pubkey %d did not match pin %p\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, p); STUB_DEBUG_SETUP_TLS, __FUNC__, i, (void *)p);
} }
return ret; return ret;

View File

@ -472,7 +472,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
HMAC_CTX ctx_space; HMAC_CTX ctx_space;
#endif #endif
DEBUG_STUB("%s %-35s: Validate TSIG\n", STUB_DEBUG_TSIG, __FUNCTION__); DEBUG_STUB("%s %-35s: Validate TSIG\n", STUB_DEBUG_TSIG, __FUNC__);
for ( rr = _getdns_rr_iter_init(&rr_spc, req->query, for ( rr = _getdns_rr_iter_init(&rr_spc, req->query,
(req->response - req->query)) (req->response - req->query))
; rr ; rr
@ -489,7 +489,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
if (request_mac_len != rdf->nxt - rdf->pos - 2) if (request_mac_len != rdf->nxt - rdf->pos - 2)
return; return;
DEBUG_STUB("%s %-35s: Request MAC found length %d\n", DEBUG_STUB("%s %-35s: Request MAC found length %d\n",
STUB_DEBUG_TSIG, __FUNCTION__, (int)(request_mac_len)); STUB_DEBUG_TSIG, __FUNC__, (int)(request_mac_len));
request_mac = rdf->pos + 2; request_mac = rdf->pos + 2;
@ -546,7 +546,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
if (response_mac_len != rdf->nxt - rdf->pos - 2) if (response_mac_len != rdf->nxt - rdf->pos - 2)
return; return;
DEBUG_STUB("%s %-35s: Response MAC found length: %d\n", DEBUG_STUB("%s %-35s: Response MAC found length: %d\n",
STUB_DEBUG_TSIG, __FUNCTION__, (int)(response_mac_len)); STUB_DEBUG_TSIG, __FUNC__, (int)(response_mac_len));
response_mac = rdf->pos + 2; response_mac = rdf->pos + 2;
if (!(rdf = _getdns_rdf_iter_next(rdf)) || if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
@ -571,7 +571,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
/* TSIG found */ /* TSIG found */
DEBUG_STUB("%s %-35s: TSIG found, original ID: %d\n", DEBUG_STUB("%s %-35s: TSIG found, original ID: %d\n",
STUB_DEBUG_TSIG, __FUNCTION__, (int)original_id); STUB_DEBUG_TSIG, __FUNC__, (int)original_id);
gldns_write_uint16(req->response + 10, gldns_write_uint16(req->response + 10,
gldns_read_uint16(req->response + 10) - 1); gldns_read_uint16(req->response + 10) - 1);
@ -612,7 +612,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
HMAC_Final(ctx, result_mac, &result_mac_len); HMAC_Final(ctx, result_mac, &result_mac_len);
DEBUG_STUB("%s %-35s: Result MAC length: %d\n", DEBUG_STUB("%s %-35s: Result MAC length: %d\n",
STUB_DEBUG_TSIG, __FUNCTION__, (int)(result_mac_len)); STUB_DEBUG_TSIG, __FUNC__, (int)(result_mac_len));
if (result_mac_len == response_mac_len && if (result_mac_len == response_mac_len &&
memcmp(result_mac, response_mac, result_mac_len) == 0) memcmp(result_mac, response_mac, result_mac_len) == 0)
req->tsig_status = GETDNS_DNSSEC_SECURE; req->tsig_status = GETDNS_DNSSEC_SECURE;

View File

@ -247,7 +247,7 @@ match_edns_opt_rr(uint16_t code, uint8_t *response, size_t response_len,
(void) gldns_wire2str_rr_scan( (void) gldns_wire2str_rr_scan(
&data, &data_len, &str, &str_len, (uint8_t *)rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt); &data, &data_len, &str, &str_len, (uint8_t *)rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt);
DEBUG_STUB("%s %-35s: OPT RR: %s\n", DEBUG_STUB("%s %-35s: OPT RR: %s\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, str_spc); STUB_DEBUG_CLEANUP, __FUNC__, str_spc);
#endif #endif
/* OPT found, now search for the specified option */ /* OPT found, now search for the specified option */
@ -339,7 +339,7 @@ process_keepalive(
else { else {
upstream->keepalive_timeout = server_keepalive; upstream->keepalive_timeout = server_keepalive;
DEBUG_STUB("%s %-35s: FD: %d Server Keepalive used: %d ms\n", DEBUG_STUB("%s %-35s: FD: %d Server Keepalive used: %d ms\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd, STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd,
(int)server_keepalive); (int)server_keepalive);
} }
} }
@ -369,7 +369,7 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport)
{ {
int fd = -1; int fd = -1;
DEBUG_STUB("%s %-35s: Creating TCP connection: %p\n", STUB_DEBUG_SETUP, DEBUG_STUB("%s %-35s: Creating TCP connection: %p\n", STUB_DEBUG_SETUP,
__FUNCTION__, upstream); __FUNC__, (void *)upstream);
if ((fd = socket(upstream->addr.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) if ((fd = socket(upstream->addr.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1)
return -1; return -1;
@ -464,7 +464,7 @@ static void
stub_cleanup(getdns_network_req *netreq) stub_cleanup(getdns_network_req *netreq)
{ {
DEBUG_STUB("%s %-35s: MSG: %p\n", DEBUG_STUB("%s %-35s: MSG: %p\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, netreq); STUB_DEBUG_CLEANUP, __FUNC__, (void *)netreq);
getdns_dns_req *dnsreq = netreq->owner; getdns_dns_req *dnsreq = netreq->owner;
getdns_network_req *r, *prev_r; getdns_network_req *r, *prev_r;
getdns_upstream *upstream; getdns_upstream *upstream;
@ -506,7 +506,7 @@ static int
tls_cleanup(getdns_upstream *upstream, int handshake_fail) tls_cleanup(getdns_upstream *upstream, int handshake_fail)
{ {
DEBUG_STUB("%s %-35s: FD: %d\n", DEBUG_STUB("%s %-35s: FD: %d\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd); STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
if (upstream->tls_obj != NULL) if (upstream->tls_obj != NULL)
SSL_free(upstream->tls_obj); SSL_free(upstream->tls_obj);
upstream->tls_obj = NULL; upstream->tls_obj = NULL;
@ -526,7 +526,7 @@ static void
upstream_erred(getdns_upstream *upstream) upstream_erred(getdns_upstream *upstream)
{ {
DEBUG_STUB("%s %-35s: FD: %d\n", DEBUG_STUB("%s %-35s: FD: %d\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd); STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
getdns_network_req *netreq; getdns_network_req *netreq;
while ((netreq = upstream->write_queue)) { while ((netreq = upstream->write_queue)) {
@ -561,7 +561,7 @@ _getdns_cancel_stub_request(getdns_network_req *netreq)
/*static void /*static void
stub_erred(getdns_network_req *netreq) stub_erred(getdns_network_req *netreq)
{ {
DEBUG_STUB("*** %s\n", __FUNCTION__); DEBUG_STUB("*** %s\n", __FUNC__);
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);
@ -574,7 +574,7 @@ stub_timeout_cb(void *userarg)
{ {
getdns_network_req *netreq = (getdns_network_req *)userarg; getdns_network_req *netreq = (getdns_network_req *)userarg;
DEBUG_STUB("%s %-35s: MSG: %p\n", DEBUG_STUB("%s %-35s: MSG: %p\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, netreq); STUB_DEBUG_CLEANUP, __FUNC__, (void *)netreq);
stub_next_upstream(netreq); stub_next_upstream(netreq);
stub_cleanup(netreq); stub_cleanup(netreq);
if (netreq->fd >= 0) if (netreq->fd >= 0)
@ -597,7 +597,7 @@ upstream_idle_timeout_cb(void *userarg)
{ {
getdns_upstream *upstream = (getdns_upstream *)userarg; getdns_upstream *upstream = (getdns_upstream *)userarg;
DEBUG_STUB("%s %-35s: FD: %d Closing connection\n", DEBUG_STUB("%s %-35s: FD: %d Closing connection\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd); STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
upstream->event.timeout_cb = NULL; upstream->event.timeout_cb = NULL;
upstream->event.read_cb = NULL; upstream->event.read_cb = NULL;
@ -610,7 +610,7 @@ upstream_tls_timeout_cb(void *userarg)
{ {
getdns_upstream *upstream = (getdns_upstream *)userarg; getdns_upstream *upstream = (getdns_upstream *)userarg;
DEBUG_STUB("%s %-35s: FD: %d\n", DEBUG_STUB("%s %-35s: FD: %d\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd); STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
/* 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, 1); tls_cleanup(upstream, 1);
@ -638,7 +638,7 @@ stub_tls_timeout_cb(void *userarg)
getdns_network_req *netreq = (getdns_network_req *)userarg; getdns_network_req *netreq = (getdns_network_req *)userarg;
getdns_upstream *upstream = netreq->upstream; getdns_upstream *upstream = netreq->upstream;
DEBUG_STUB("%s %-35s: MSG: %p\n", DEBUG_STUB("%s %-35s: MSG: %p\n",
STUB_DEBUG_CLEANUP, __FUNCTION__, netreq); STUB_DEBUG_CLEANUP, __FUNC__, (void *)netreq);
/* 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, 0); tls_cleanup(upstream, 0);
@ -773,7 +773,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
netreq->owner->context->idle_timeout != 0) { netreq->owner->context->idle_timeout != 0) {
/* Add the keepalive option to the first query on this connection*/ /* Add the keepalive option to the first query on this connection*/
DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n", DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n",
STUB_DEBUG_WRITE, __FUNCTION__, fd); STUB_DEBUG_WRITE, __FUNC__, fd);
if (attach_edns_keepalive(netreq)) if (attach_edns_keepalive(netreq))
return STUB_OUT_OF_OPTIONS; return STUB_OUT_OF_OPTIONS;
netreq->keepalive_sent = 1; netreq->keepalive_sent = 1;
@ -904,7 +904,7 @@ tls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
int err = X509_STORE_CTX_get_error(ctx); int err = X509_STORE_CTX_get_error(ctx);
DEBUG_STUB("%s %-35s: FD: %d Verify result: (%d) \"%s\"\n", DEBUG_STUB("%s %-35s: FD: %d Verify result: (%d) \"%s\"\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, err, STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd, err,
X509_verify_cert_error_string(err)); X509_verify_cert_error_string(err));
#endif #endif
@ -912,19 +912,19 @@ tls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
/*Report if error is hostname mismatch*/ /*Report if error is hostname mismatch*/
if (upstream && upstream->tls_fallback_ok && err == X509_V_ERR_HOSTNAME_MISMATCH) if (upstream && upstream->tls_fallback_ok && err == X509_V_ERR_HOSTNAME_MISMATCH)
DEBUG_STUB("%s %-35s: FD: %d WARNING: Proceeding even though hostname validation failed!\n", DEBUG_STUB("%s %-35s: FD: %d WARNING: Proceeding even though hostname validation failed!\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd); STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
#endif #endif
if (upstream && upstream->tls_pubkey_pinset) if (upstream && upstream->tls_pubkey_pinset)
pinset_ret = _getdns_verify_pinset_match(upstream->tls_pubkey_pinset, ctx); pinset_ret = _getdns_verify_pinset_match(upstream->tls_pubkey_pinset, ctx);
if (pinset_ret != GETDNS_RETURN_GOOD) { if (pinset_ret != GETDNS_RETURN_GOOD) {
DEBUG_STUB("%s %-35s: FD: %d, WARNING: Pinset validation failure!\n", DEBUG_STUB("%s %-35s: FD: %d, WARNING: Pinset validation failure!\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd); STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
preverify_ok = 0; preverify_ok = 0;
upstream->tls_auth_failed = 1; upstream->tls_auth_failed = 1;
if (upstream->tls_fallback_ok) if (upstream->tls_fallback_ok)
DEBUG_STUB("%s %-35s: FD: %d, WARNING: Proceeding even though pinset validation failed!\n", DEBUG_STUB("%s %-35s: FD: %d, WARNING: Proceeding even though pinset validation failed!\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd); STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
} }
/* If fallback is allowed, proceed regardless of what the auth error is /* If fallback is allowed, proceed regardless of what the auth error is
(might not be hostname or pinset related) */ (might not be hostname or pinset related) */
@ -961,7 +961,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (upstream->tls_auth_name[0] != '\0') { if (upstream->tls_auth_name[0] != '\0') {
/*Request certificate for the auth_name*/ /*Request certificate for the auth_name*/
DEBUG_STUB("%s %-35s: Hostname verification requested for: %s\n", DEBUG_STUB("%s %-35s: Hostname verification requested for: %s\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->tls_auth_name); STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->tls_auth_name);
SSL_set_tlsext_host_name(ssl, upstream->tls_auth_name); SSL_set_tlsext_host_name(ssl, upstream->tls_auth_name);
#ifdef HAVE_SSL_HN_AUTH #ifdef HAVE_SSL_HN_AUTH
/* Set up native OpenSSL hostname verification*/ /* Set up native OpenSSL hostname verification*/
@ -973,7 +973,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) { if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) {
/* TODO: Trigger post-handshake custom validation*/ /* TODO: Trigger post-handshake custom validation*/
DEBUG_STUB("%s %-35s: ERROR: TLS Authentication functionality not available\n", DEBUG_STUB("%s %-35s: ERROR: TLS Authentication functionality not available\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__); STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_hs_state = GETDNS_HS_FAILED; upstream->tls_hs_state = GETDNS_HS_FAILED;
upstream->tls_auth_failed = 1; upstream->tls_auth_failed = 1;
return NULL; return NULL;
@ -988,10 +988,10 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) { if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) {
if (upstream->tls_pubkey_pinset) { if (upstream->tls_pubkey_pinset) {
DEBUG_STUB("%s %-35s: Proceeding with only pubkey pinning authentication\n", DEBUG_STUB("%s %-35s: Proceeding with only pubkey pinning authentication\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__); STUB_DEBUG_SETUP_TLS, __FUNC__);
} else { } else {
DEBUG_STUB("%s %-35s: ERROR: No host name or pubkey pinset provided for TLS authentication\n", DEBUG_STUB("%s %-35s: ERROR: No host name or pubkey pinset provided for TLS authentication\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__); STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_hs_state = GETDNS_HS_FAILED; upstream->tls_hs_state = GETDNS_HS_FAILED;
upstream->tls_auth_failed = 1; upstream->tls_auth_failed = 1;
return NULL; return NULL;
@ -999,7 +999,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
} else { } else {
/* no hostname verification, so we will make opportunistic connections */ /* no hostname verification, so we will make opportunistic connections */
DEBUG_STUB("%s %-35s: Proceeding even though no hostname provided!\n", DEBUG_STUB("%s %-35s: Proceeding even though no hostname provided!\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__); STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_auth_failed = 1; upstream->tls_auth_failed = 1;
upstream->tls_fallback_ok = 1; upstream->tls_fallback_ok = 1;
} }
@ -1007,10 +1007,10 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (upstream->tls_fallback_ok) { if (upstream->tls_fallback_ok) {
SSL_set_cipher_list(ssl, "DEFAULT"); SSL_set_cipher_list(ssl, "DEFAULT");
DEBUG_STUB("%s %-35s: WARNING: Using Oppotunistic TLS (fallback allowed)!\n", DEBUG_STUB("%s %-35s: WARNING: Using Oppotunistic TLS (fallback allowed)!\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__); STUB_DEBUG_SETUP_TLS, __FUNC__);
} else } else
DEBUG_STUB("%s %-35s: Using Strict TLS \n", STUB_DEBUG_SETUP_TLS, DEBUG_STUB("%s %-35s: Using Strict TLS \n", STUB_DEBUG_SETUP_TLS,
__FUNCTION__); __FUNC__);
SSL_set_verify(ssl, SSL_VERIFY_PEER, tls_verify_callback); SSL_set_verify(ssl, SSL_VERIFY_PEER, tls_verify_callback);
SSL_set_connect_state(ssl); SSL_set_connect_state(ssl);
@ -1022,7 +1022,7 @@ static int
tls_do_handshake(getdns_upstream *upstream) tls_do_handshake(getdns_upstream *upstream)
{ {
DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SETUP_TLS, DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SETUP_TLS,
__FUNCTION__, upstream->fd); __FUNC__, upstream->fd);
int r; int r;
int want; int want;
ERR_clear_error(); ERR_clear_error();
@ -1048,14 +1048,14 @@ tls_do_handshake(getdns_upstream *upstream)
return STUB_TCP_AGAIN; return STUB_TCP_AGAIN;
default: default:
DEBUG_STUB("%s %-35s: FD: %d Handshake failed %d\n", DEBUG_STUB("%s %-35s: FD: %d Handshake failed %d\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd,
want); want);
return tls_cleanup(upstream, 1); return tls_cleanup(upstream, 1);
} }
} }
upstream->tls_hs_state = GETDNS_HS_DONE; upstream->tls_hs_state = GETDNS_HS_DONE;
DEBUG_STUB("%s %-35s: FD: %d Handshake succeeded\n", DEBUG_STUB("%s %-35s: FD: %d Handshake succeeded\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd); STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
r = SSL_get_verify_result(upstream->tls_obj); r = SSL_get_verify_result(upstream->tls_obj);
if (upstream->tls_auth_name[0]) if (upstream->tls_auth_name[0])
#ifdef X509_V_ERR_HOSTNAME_MISMATCH #ifdef X509_V_ERR_HOSTNAME_MISMATCH
@ -1067,7 +1067,7 @@ tls_do_handshake(getdns_upstream *upstream)
#endif #endif
upstream->tls_auth_failed = 1; upstream->tls_auth_failed = 1;
DEBUG_STUB("%s %-35s: FD: %d Session is %s\n", DEBUG_STUB("%s %-35s: FD: %d Session is %s\n",
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd,
SSL_session_reused(upstream->tls_obj) ?"re-used":"new"); SSL_session_reused(upstream->tls_obj) ?"re-used":"new");
if (upstream->tls_session != NULL) if (upstream->tls_session != NULL)
SSL_SESSION_free(upstream->tls_session); SSL_SESSION_free(upstream->tls_session);
@ -1242,7 +1242,7 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
/* Add the keepalive option to every nth query on this /* Add the keepalive option to every nth query on this
connection */ connection */
DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n", DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n",
STUB_DEBUG_SETUP, __FUNCTION__, upstream->fd); STUB_DEBUG_SETUP, __FUNC__, upstream->fd);
if (attach_edns_keepalive(netreq)) if (attach_edns_keepalive(netreq))
return STUB_OUT_OF_OPTIONS; return STUB_OUT_OF_OPTIONS;
netreq->keepalive_sent = 1; netreq->keepalive_sent = 1;
@ -1304,7 +1304,7 @@ stub_udp_read_cb(void *userarg)
getdns_upstream *upstream = netreq->upstream; getdns_upstream *upstream = netreq->upstream;
ssize_t read; ssize_t read;
DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_READ, DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_READ,
__FUNCTION__, netreq); __FUNC__, (void *)netreq);
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event); GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
@ -1336,7 +1336,7 @@ stub_udp_read_cb(void *userarg)
#endif #endif
while (GLDNS_TC_WIRE(netreq->response)) { while (GLDNS_TC_WIRE(netreq->response)) {
DEBUG_STUB("%s %-35s: MSG: %p TC bit set in response \n", STUB_DEBUG_READ, DEBUG_STUB("%s %-35s: MSG: %p TC bit set in response \n", STUB_DEBUG_READ,
__FUNCTION__, netreq); __FUNC__, (void *)netreq);
if (!(netreq->transport_current < netreq->transport_count)) if (!(netreq->transport_current < netreq->transport_count))
break; break;
getdns_transport_list_t next_transport = getdns_transport_list_t next_transport =
@ -1370,7 +1370,7 @@ stub_udp_write_cb(void *userarg)
getdns_dns_req *dnsreq = netreq->owner; getdns_dns_req *dnsreq = netreq->owner;
size_t pkt_len; size_t pkt_len;
DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_WRITE, DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_WRITE,
__FUNCTION__, netreq); __FUNC__, (void *)netreq);
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event); GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
@ -1436,7 +1436,7 @@ static void
upstream_read_cb(void *userarg) upstream_read_cb(void *userarg)
{ {
getdns_upstream *upstream = (getdns_upstream *)userarg; getdns_upstream *upstream = (getdns_upstream *)userarg;
DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_READ, __FUNCTION__, DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_READ, __FUNC__,
upstream->fd); upstream->fd);
getdns_network_req *netreq; getdns_network_req *netreq;
int q; int q;
@ -1477,7 +1477,7 @@ upstream_read_cb(void *userarg)
} }
DEBUG_STUB("%s %-35s: MSG: %p (read)\n", DEBUG_STUB("%s %-35s: MSG: %p (read)\n",
STUB_DEBUG_READ, __FUNCTION__, netreq); STUB_DEBUG_READ, __FUNC__, (void *)netreq);
netreq->state = NET_REQ_FINISHED; netreq->state = NET_REQ_FINISHED;
netreq->response = upstream->tcp.read_buf; netreq->response = upstream->tcp.read_buf;
netreq->response_len = netreq->response_len =
@ -1561,7 +1561,7 @@ upstream_write_cb(void *userarg)
/* TODO: think about TCP AGAIN */ /* TODO: think about TCP AGAIN */
netreq->debug_start_time = _getdns_get_time_as_uintt64(); netreq->debug_start_time = _getdns_get_time_as_uintt64();
DEBUG_STUB("%s %-35s: MSG: %p (writing)\n", STUB_DEBUG_WRITE, DEBUG_STUB("%s %-35s: MSG: %p (writing)\n", STUB_DEBUG_WRITE,
__FUNCTION__, netreq); __FUNC__, (void *)netreq);
if (tls_requested(netreq) && tls_should_write(upstream)) if (tls_requested(netreq) && tls_should_write(upstream))
q = stub_tls_write(upstream, &upstream->tcp, netreq); q = stub_tls_write(upstream, &upstream->tcp, netreq);
@ -1579,7 +1579,7 @@ upstream_write_cb(void *userarg)
case STUB_TCP_ERROR: case STUB_TCP_ERROR:
/* Problem with the TCP connection itself. Need to fallback.*/ /* Problem with the TCP connection itself. Need to fallback.*/
DEBUG_STUB("%s %-35s: MSG: %p ERROR!\n", STUB_DEBUG_WRITE, DEBUG_STUB("%s %-35s: MSG: %p ERROR!\n", STUB_DEBUG_WRITE,
__FUNCTION__, ((getdns_network_req *)userarg)); __FUNC__, userarg);
upstream->tcp.write_error = 1; upstream->tcp.write_error = 1;
/* Use policy of trying next upstream in this case. Need more work on /* Use policy of trying next upstream in this case. Need more work on
* TCP connection re-use.*/ * TCP connection re-use.*/
@ -1672,14 +1672,14 @@ upstream_select(getdns_network_req *netreq, getdns_transport_list_t transport)
/* transport type and/or maintain separate current for transports?*/ /* transport type and/or maintain separate current for transports?*/
i = upstreams->current; i = upstreams->current;
DEBUG_STUB("%s %-35s: Starting from upstream: %d of %d available \n", STUB_DEBUG_SETUP, DEBUG_STUB("%s %-35s: Starting from upstream: %d of %d available \n", STUB_DEBUG_SETUP,
__FUNCTION__, (int)i, (int)upstreams->count); __FUNC__, (int)i, (int)upstreams->count);
do { do {
if (upstreams->upstreams[i].to_retry > 0 && if (upstreams->upstreams[i].to_retry > 0 &&
upstream_transport_valid(&upstreams->upstreams[i], transport, netreq)) { upstream_transport_valid(&upstreams->upstreams[i], transport, netreq)) {
upstreams->current = i; upstreams->current = i;
DEBUG_STUB("%s %-35s: Selected upstream: %d %p transport: %d\n", DEBUG_STUB("%s %-35s: Selected upstream: %d %p transport: %d\n",
STUB_DEBUG_SETUP, __FUNCTION__, (int)i, STUB_DEBUG_SETUP, __FUNC__, (int)i,
&upstreams->upstreams[i], transport); (void *)&upstreams->upstreams[i], transport);
return &upstreams->upstreams[i]; return &upstreams->upstreams[i];
} }
if (++i >= upstreams->count) if (++i >= upstreams->count)
@ -1695,7 +1695,7 @@ upstream_select(getdns_network_req *netreq, getdns_transport_list_t transport)
/* Need to check again that the transport is valid */ /* Need to check again that the transport is valid */
if (!upstream_transport_valid(upstream, transport, netreq)) { if (!upstream_transport_valid(upstream, transport, netreq)) {
DEBUG_STUB("%s %-35s: No valid upstream available for transport %d!\n", DEBUG_STUB("%s %-35s: No valid upstream available for transport %d!\n",
STUB_DEBUG_SETUP, __FUNCTION__, transport); STUB_DEBUG_SETUP, __FUNC__, transport);
return NULL; return NULL;
} }
upstream->back_off++; upstream->back_off++;
@ -1710,7 +1710,7 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport,
getdns_dns_req *dnsreq) getdns_dns_req *dnsreq)
{ {
DEBUG_STUB("%s %-35s: Checking upstream connection: %p\n", STUB_DEBUG_SETUP, DEBUG_STUB("%s %-35s: Checking upstream connection: %p\n", STUB_DEBUG_SETUP,
__FUNCTION__, upstream); __FUNC__, (void *)upstream);
int fd = -1; int fd = -1;
switch(transport) { switch(transport) {
case GETDNS_TRANSPORT_UDP: case GETDNS_TRANSPORT_UDP:
@ -1771,7 +1771,7 @@ upstream_find_for_transport(getdns_network_req *netreq,
return NULL; return NULL;
*fd = upstream_connect(upstream, transport, netreq->owner); *fd = upstream_connect(upstream, transport, netreq->owner);
DEBUG_STUB("%s %-35s: FD: %d Connected for upstream: %p\n", DEBUG_STUB("%s %-35s: FD: %d Connected for upstream: %p\n",
STUB_DEBUG_SETUP, __FUNCTION__, *fd, upstream); STUB_DEBUG_SETUP, __FUNC__, *fd, (void *)upstream);
return upstream; return upstream;
} }
@ -1805,7 +1805,7 @@ fallback_on_write(getdns_network_req *netreq)
/* Deal with UDP and change error code*/ /* Deal with UDP and change error code*/
DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq); DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNC__, (void *)netreq);
/* Try to find a fallback transport*/ /* Try to find a fallback transport*/
getdns_return_t result = _getdns_submit_stub_request(netreq); getdns_return_t result = _getdns_submit_stub_request(netreq);
@ -1822,7 +1822,7 @@ static void
upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) { upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) {
DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SCHEDULE, DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SCHEDULE,
__FUNCTION__, upstream->fd); __FUNC__, upstream->fd);
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
if (!upstream->write_queue && upstream->event.write_cb) { if (!upstream->write_queue && upstream->event.write_cb) {
upstream->event.write_cb = NULL; upstream->event.write_cb = NULL;
@ -1841,7 +1841,7 @@ upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) {
upstream->fd, TIMEOUT_FOREVER, &upstream->event); upstream->fd, TIMEOUT_FOREVER, &upstream->event);
else { else {
DEBUG_STUB("%s %-35s: FD: %d Connection idle - timeout is %d\n", DEBUG_STUB("%s %-35s: FD: %d Connection idle - timeout is %d\n",
STUB_DEBUG_SCHEDULE, __FUNCTION__, upstream->fd, (int)idle_timeout); STUB_DEBUG_SCHEDULE, __FUNC__, upstream->fd, (int)idle_timeout);
upstream->event.timeout_cb = upstream_idle_timeout_cb; upstream->event.timeout_cb = upstream_idle_timeout_cb;
if (upstream->tcp.write_error != 0) if (upstream->tcp.write_error != 0)
idle_timeout = 0; idle_timeout = 0;
@ -1853,7 +1853,7 @@ upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) {
static void static void
upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq) upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
{ {
DEBUG_STUB("%s %-35s: MSG: %p (schedule event)\n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq); DEBUG_STUB("%s %-35s: MSG: %p (schedule event)\n", STUB_DEBUG_SCHEDULE, __FUNC__, (void *)netreq);
/* 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);
@ -1906,8 +1906,8 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
getdns_return_t getdns_return_t
_getdns_submit_stub_request(getdns_network_req *netreq) _getdns_submit_stub_request(getdns_network_req *netreq)
{ {
DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNCTION__, DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNC__,
netreq, netreq->request_type); (void *)netreq, netreq->request_type);
int fd = -1; int fd = -1;
getdns_dns_req *dnsreq = netreq->owner; getdns_dns_req *dnsreq = netreq->owner;

View File

@ -616,7 +616,7 @@ static void free_listen_set_when_done(listen_set *set)
if (!(mf = priv_getdns_context_mf(set->context))) if (!(mf = priv_getdns_context_mf(set->context)))
return; return;
DEBUG_SERVER("To free listen set: %p\n", set); DEBUG_SERVER("To free listen set: %p\n", (void *)set);
for (i = 0; i < set->count; i++) { for (i = 0; i < set->count; i++) {
listener *l = &set->items[i]; listener *l = &set->items[i];
@ -627,7 +627,7 @@ static void free_listen_set_when_done(listen_set *set)
return; return;
} }
GETDNS_FREE(*mf, set); GETDNS_FREE(*mf, set);
DEBUG_SERVER("Listen set: %p freed\n", set); DEBUG_SERVER("Listen set: %p freed\n", (void *)set);
} }
static void remove_listeners(listen_set *set) static void remove_listeners(listen_set *set)
@ -761,8 +761,8 @@ getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
size_t i; size_t i;
struct addrinfo hints; struct addrinfo hints;
DEBUG_SERVER("getdns_context_set_listen_addresses(%p, %p, %p)\n", context, request_handler, DEBUG_SERVER("getdns_context_set_listen_addresses(%p, <func>, %p)\n",
listen_addresses); (void *)context, (void *)listen_addresses);
if (!(mf = priv_getdns_context_mf(context))) if (!(mf = priv_getdns_context_mf(context)))
return GETDNS_RETURN_GENERIC_ERROR; return GETDNS_RETURN_GENERIC_ERROR;
@ -796,7 +796,8 @@ getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
sizeof(listener) * new_set_count * n_transports))) sizeof(listener) * new_set_count * n_transports)))
return GETDNS_RETURN_MEMORY_ERROR; return GETDNS_RETURN_MEMORY_ERROR;
DEBUG_SERVER("New listen set: %p, current_set: %p\n", new_set, current_set); DEBUG_SERVER("New listen set: %p, current_set: %p\n",
(void *)new_set, (void *)current_set);
new_set->context = context; new_set->context = context;
new_set->next = root; new_set->next = root;

View File

@ -1288,7 +1288,7 @@ static void request_cb(
(void)transaction_id; (void)transaction_id;
#endif #endif
DEBUG_SERVER("reply for: %p %"PRIu64" %d (edns0: %d, do: %d, ad: %d," DEBUG_SERVER("reply for: %p %"PRIu64" %d (edns0: %d, do: %d, ad: %d,"
" cd: %d)\n", msg, transaction_id, (int)callback_type, " cd: %d)\n", (void *)msg, transaction_id, (int)callback_type,
msg->has_edns0, msg->do_bit, msg->ad_bit, msg->cd_bit); msg->has_edns0, msg->do_bit, msg->ad_bit, msg->cd_bit);
assert(msg); assert(msg);
@ -1498,7 +1498,7 @@ static void incoming_request_handler(getdns_context *context,
getdns_get_errorstr_by_id(r)); getdns_get_errorstr_by_id(r));
else { else {
DEBUG_SERVER("scheduled: %p %"PRIu64" for %s %d\n", DEBUG_SERVER("scheduled: %p %"PRIu64" for %s %d\n",
msg, transaction_id, qname_str, (int)qtype); (void *)msg, transaction_id, qname_str, (int)qtype);
free(qname_str); free(qname_str);
return; return;
} }

View File

@ -1,16 +0,0 @@
BaseName: 315-event-loops-compile
Version: 1.0
Description: Compile
CreationDate: do 8 dec 2016 23:38:18 CET
Maintainer: Willem Toorop
Category:
Component:
CmdDepends:
Depends: 300-event-loops-configure.tpkg
Help:
Pre: 315-event-loops-compile.pre
Post: 315-event-loops-compile.post
Test: 315-event-loops-compile.test
AuxFiles:
Passed:
Failure:

View File

@ -1,20 +0,0 @@
# #-- 315-event-loops-compile.post --#
# source the master var file when it's there
if [ -f ../.tpkg.var.master ]
then
source ../.tpkg.var.master
else
(
cd ..
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
&& sh "${TPKG_SRCDIR}/setup-env.sh"
) && source ../.tpkg.var.master
fi
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
for f in `cat restore-srcdir-configure-settings`
do
mv "${SRCROOT}/${f}.build-event-loops" "${SRCROOT}/${f}"
done

View File

@ -1,24 +0,0 @@
# #-- 315-event-loops-compile.pre--#
# source the master var file when it's there
if [ -f ../.tpkg.var.master ]
then
source ../.tpkg.var.master
else
(
cd ..
[ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
&& sh "${TPKG_SRCDIR}/setup-env.sh"
) && source ../.tpkg.var.master
fi
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
echo "" > restore-srcdir-configure-settings
for f in `grep 'CONFIG_[FH][IE][LA][ED][SE]' "${SRCROOT}/configure.ac" | sed -e 's/^.*(\[//g' -e 's/\])//g'`
do
if [ -f "${SRCROOT}/$f" ]
then
mv "${SRCROOT}/${f}" "${SRCROOT}/${f}.build-event-loops" && \
echo "$f" >> restore-srcdir-configure-settings
fi
done

View File

@ -1,8 +0,0 @@
# #-- 315-event-loops-compile.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build-event-loops"
make XTRA_CFLAGS='-Werror'

View File

@ -5,5 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test [ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build-event-loops" cd "${BUILDDIR}/build-event-loops"
make clean make XTRA_CFLAGS=-Werror
make

View File

@ -149,7 +149,7 @@ static int my_event_base_loopexit(struct ub_event_base* base, struct timeval* tv
static void clear_my_event(my_event *ev) static void clear_my_event(my_event *ev)
{ {
DEBUG_SCHED("UB_LOOP: to clear %p(%d, %d, %"PRIu64"), total: %d\n" DEBUG_SCHED("UB_LOOP: to clear %p(%d, %d, %"PRIu64"), total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events); , (void *)ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
(ev)->loop->extension->vmt->clear((ev)->loop->extension, &(ev)->gev); (ev)->loop->extension->vmt->clear((ev)->loop->extension, &(ev)->gev);
(ev)->added = 0; (ev)->added = 0;
if ((ev)->active) { if ((ev)->active) {
@ -157,7 +157,7 @@ static void clear_my_event(my_event *ev)
(ev)->active = NULL; (ev)->active = NULL;
} }
DEBUG_SCHED("UB_LOOP: %p(%d, %d, %"PRIu64") cleared, total: %d\n" DEBUG_SCHED("UB_LOOP: %p(%d, %d, %"PRIu64") cleared, total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, --ev->loop->n_events); , (void *)ev, ev->fd, ev->bits, ev->timeout, --ev->loop->n_events);
} }
static getdns_return_t schedule_my_event(my_event *ev) static getdns_return_t schedule_my_event(my_event *ev)
@ -165,16 +165,16 @@ static getdns_return_t schedule_my_event(my_event *ev)
getdns_return_t r; getdns_return_t r;
DEBUG_SCHED("UB_LOOP: to schedule %p(%d, %d, %"PRIu64"), total: %d\n" DEBUG_SCHED("UB_LOOP: to schedule %p(%d, %d, %"PRIu64"), total: %d\n"
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events); , (void *)ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
if (ev->gev.read_cb || ev->gev.write_cb || ev->gev.timeout_cb) { if (ev->gev.read_cb || ev->gev.write_cb || ev->gev.timeout_cb) {
if ((r = ev->loop->extension->vmt->schedule( if ((r = ev->loop->extension->vmt->schedule(
ev->loop->extension, ev->fd, ev->timeout, &ev->gev))) { ev->loop->extension, ev->fd, ev->timeout, &ev->gev))) {
DEBUG_SCHED("UB_LOOP ERROR: scheduling event: %p\n", ev); DEBUG_SCHED("UB_LOOP ERROR: scheduling event: %p\n", (void *)ev);
return r; return r;
} }
ev->added = 1; ev->added = 1;
DEBUG_SCHED("UB_LOOP: event %p(%d, %d, %"PRIu64") scheduled, " DEBUG_SCHED("UB_LOOP: event %p(%d, %d, %"PRIu64") scheduled, "
"total: %d\n", ev, ev->fd, ev->bits, ev->timeout "total: %d\n", (void *)ev, ev->fd, ev->bits, ev->timeout
, ++ev->loop->n_events); , ++ev->loop->n_events);
} }
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;