diff --git a/configure.ac b/configure.ac index 3cb6d24c..fa6a2436 100644 --- a/configure.ac +++ b/configure.ac @@ -1011,7 +1011,10 @@ fi #---- check for pthreads library -AC_SEARCH_LIBS([pthread_mutex_init],[pthread],[AC_DEFINE([HAVE_PTHREAD], [1], [Have pthreads library])], [AC_MSG_WARN([pthreads not available])]) +AC_SEARCH_LIBS([pthread_mutex_init],[pthread], [ + AC_DEFINE([HAVE_PTHREAD], [1], [Have pthreads library]) + LIBS="-lpthread $LIBS" +], [AC_MSG_WARN([pthreads not available])]) AC_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable]) AC_LANG_PUSH(C) diff --git a/src/general.c b/src/general.c index 6ed44004..8d780eb7 100644 --- a/src/general.c +++ b/src/general.c @@ -110,7 +110,8 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req) /* Do we have to check more suffixes on nxdomain/nodata? */ - if (dns_req->suffix_appended && /* Something was appended */ + if (dns_req->is_dns_request && + dns_req->suffix_appended && /* Something was appended */ dns_req->suffix_len > 1 && /* Next suffix available */ no_answer(dns_req)) { /* Remove suffix from name */ @@ -146,6 +147,7 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req) return; } } else if ( + dns_req->is_dns_request && ( dns_req->append_name == GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE || dns_req->append_name == @@ -189,7 +191,9 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req) dns_req->internal_cb(dns_req); } else if (! results_found) _getdns_call_user_callback(dns_req, NULL); - else if (dns_req->dnssec_return_validation_chain + else if ( + dns_req->is_dns_request && + (dns_req->dnssec_return_validation_chain #ifdef DNSSEC_ROADBLOCK_AVOIDANCE || ( dns_req->dnssec_roadblock_avoidance && !dns_req->avoid_dnssec_roadblocks) @@ -202,7 +206,7 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req) dns_req->dnssec_return_all_statuses )) #endif - ) + )) _getdns_get_validation_chain(dns_req); else _getdns_call_user_callback( @@ -301,7 +305,7 @@ _getdns_netreq_change_state( uint64_t now_ms; getdns_network_req *prev; - if (!netreq) + if (!netreq || !netreq->owner->is_dns_request) return; context = netreq->owner->context; @@ -571,7 +575,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop, if (!(r = _getdns_context_local_namespace_resolve( req, &localnames_response))) { - + req->is_dns_request = 0; _getdns_call_user_callback ( req, localnames_response); break; @@ -581,6 +585,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop, /* Check whether the name belongs in the MDNS space */ if (!(r = _getdns_mdns_namespace_check(req))) { + req->is_dns_request = 0; // Submit the query to the MDNS transport. for (netreq_p = req->netreqs ; !r && (netreq = *netreq_p) diff --git a/src/mdns.c b/src/mdns.c index b18368ff..6373b265 100644 --- a/src/mdns.c +++ b/src/mdns.c @@ -513,7 +513,7 @@ static void msdn_cache_deldata(void* vdata, void* vcontext) /* TODO: treating as a timeout for now, may consider treating as error */ netreq->debug_end_time = _getdns_get_time_as_uintt64(); - netreq->state = NET_REQ_TIMED_OUT; + _getdns_netreq_change_state(netreq, NET_REQ_TIMED_OUT); if (netreq->owner->user_callback) { (void)_getdns_context_request_timed_out(netreq->owner); } @@ -1008,7 +1008,7 @@ mdns_complete_query_from_cache_entry( netreq->response_len = packet_length; netreq->debug_end_time = _getdns_get_time_as_uintt64(); - netreq->state = NET_REQ_FINISHED; + _getdns_netreq_change_state(netreq, NET_REQ_FINISHED); _getdns_check_dns_req_complete(netreq->owner); } else @@ -1016,7 +1016,7 @@ mdns_complete_query_from_cache_entry( /* Fail the query? */ netreq->response_len = 0; netreq->debug_end_time = _getdns_get_time_as_uintt64(); - netreq->state = NET_REQ_ERRORED; + _getdns_netreq_change_state(netreq, NET_REQ_ERRORED); _getdns_check_dns_req_complete(netreq->owner); } } @@ -1026,7 +1026,7 @@ mdns_complete_query_from_cache_entry( /* Failure */ netreq->response_len = 0; netreq->debug_end_time = _getdns_get_time_as_uintt64(); - netreq->state = NET_REQ_ERRORED; + _getdns_netreq_change_state(netreq, NET_REQ_ERRORED); _getdns_check_dns_req_complete(netreq->owner); } @@ -1085,7 +1085,7 @@ mdns_mcast_timeout_cb(void *userarg) int found = 0; DEBUG_MDNS("%s %-35s: MSG: %p\n", - MDNS_DEBUG_CLEANUP, __FUNCTION__, netreq); + MDNS_DEBUG_CLEANUP, __FUNC__, netreq); msdn_cache_create_key_in_buffer(temp_key, dnsreq->name, dnsreq->name_len, netreq->request_type, dnsreq->request_class); @@ -1113,7 +1113,7 @@ mdns_mcast_timeout_cb(void *userarg) /* Fail the request on timeout */ netreq->response_len = 0; netreq->debug_end_time = _getdns_get_time_as_uintt64(); - netreq->state = NET_REQ_ERRORED; + _getdns_netreq_change_state(netreq, NET_REQ_ERRORED); _getdns_check_dns_req_complete(netreq->owner); } } @@ -1128,7 +1128,7 @@ mdns_udp_multicast_read_cb(void *userarg) uint64_t current_time; ssize_t read; DEBUG_MDNS("%s %-35s: CTX: %p, NET=%d \n", MDNS_DEBUG_MREAD, - __FUNCTION__, cnx->context, cnx->addr_mcast.ss_family); + __FUNC__, cnx->context, cnx->addr_mcast.ss_family); current_time = _getdns_get_time_as_uintt64(); diff --git a/src/request-internal.c b/src/request-internal.c index 2259286e..a74fe8f0 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -938,6 +938,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop, result->finished_next = NULL; result->freed = NULL; result->validating = 0; + result->is_dns_request = 1; result->chain = NULL; network_req_init(result->netreqs[0], result, diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test index b0360279..b628a657 100644 --- a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test +++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test @@ -15,7 +15,8 @@ rm -f report.txt echo "*** running out of filedescriptors (sockets) and for the" echo "*** limit_outstanding_queries feature." echo "*** " - grep '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] + grep -n '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] | \ + grep -v '^request-internal.c:[12][0-9][0-9]: *net_req->state = NET_REQ_NOT_SENT;$' echo "" fi ) >> report.txt @@ -28,7 +29,7 @@ rm -f report.txt echo "*** __FUNC__ is aliases in config.h to name to be used" echo "*** for the system with a #define" echo "*** " - grep '__FUNCION__' *.[ch] */*.[ch] + grep -n '__FUNCTION__' *.[ch] */*.[ch] echo "" fi ) >> report.txt diff --git a/src/types-internal.h b/src/types-internal.h index ad1e9806..856651a3 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -313,6 +313,7 @@ typedef struct getdns_dns_req { /* Internally used by return_validation_chain */ unsigned dnssec_ok_checking_disabled : 1; unsigned is_sync_request : 1; + unsigned is_dns_request : 1; /* The validating and freed variables are used to make sure a single * code path is followed while processing a DNS request, even when