mirror of https://github.com/getdnsapi/getdns.git
Fit mdns code with pending dns netreqs on EMFILE
This commit is contained in:
parent
ed0d4d044c
commit
24abf43de1
|
@ -1011,7 +1011,10 @@ fi
|
||||||
|
|
||||||
|
|
||||||
#---- check for pthreads library
|
#---- 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_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable])
|
||||||
AC_LANG_PUSH(C)
|
AC_LANG_PUSH(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?
|
/* 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 */
|
dns_req->suffix_len > 1 && /* Next suffix available */
|
||||||
no_answer(dns_req)) {
|
no_answer(dns_req)) {
|
||||||
/* Remove suffix from name */
|
/* Remove suffix from name */
|
||||||
|
@ -146,6 +147,7 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
dns_req->is_dns_request &&
|
||||||
( dns_req->append_name ==
|
( dns_req->append_name ==
|
||||||
GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE ||
|
GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE ||
|
||||||
dns_req->append_name ==
|
dns_req->append_name ==
|
||||||
|
@ -189,7 +191,9 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
|
||||||
dns_req->internal_cb(dns_req);
|
dns_req->internal_cb(dns_req);
|
||||||
} else if (! results_found)
|
} else if (! results_found)
|
||||||
_getdns_call_user_callback(dns_req, NULL);
|
_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
|
#ifdef DNSSEC_ROADBLOCK_AVOIDANCE
|
||||||
|| ( dns_req->dnssec_roadblock_avoidance
|
|| ( dns_req->dnssec_roadblock_avoidance
|
||||||
&& !dns_req->avoid_dnssec_roadblocks)
|
&& !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
|
dns_req->dnssec_return_all_statuses
|
||||||
))
|
))
|
||||||
#endif
|
#endif
|
||||||
)
|
))
|
||||||
_getdns_get_validation_chain(dns_req);
|
_getdns_get_validation_chain(dns_req);
|
||||||
else
|
else
|
||||||
_getdns_call_user_callback(
|
_getdns_call_user_callback(
|
||||||
|
@ -301,7 +305,7 @@ _getdns_netreq_change_state(
|
||||||
uint64_t now_ms;
|
uint64_t now_ms;
|
||||||
getdns_network_req *prev;
|
getdns_network_req *prev;
|
||||||
|
|
||||||
if (!netreq)
|
if (!netreq || !netreq->owner->is_dns_request)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context = netreq->owner->context;
|
context = netreq->owner->context;
|
||||||
|
@ -571,7 +575,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
|
||||||
|
|
||||||
if (!(r = _getdns_context_local_namespace_resolve(
|
if (!(r = _getdns_context_local_namespace_resolve(
|
||||||
req, &localnames_response))) {
|
req, &localnames_response))) {
|
||||||
|
req->is_dns_request = 0;
|
||||||
_getdns_call_user_callback
|
_getdns_call_user_callback
|
||||||
( req, localnames_response);
|
( req, localnames_response);
|
||||||
break;
|
break;
|
||||||
|
@ -581,6 +585,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
|
||||||
/* Check whether the name belongs in the MDNS space */
|
/* Check whether the name belongs in the MDNS space */
|
||||||
if (!(r = _getdns_mdns_namespace_check(req)))
|
if (!(r = _getdns_mdns_namespace_check(req)))
|
||||||
{
|
{
|
||||||
|
req->is_dns_request = 0;
|
||||||
// Submit the query to the MDNS transport.
|
// Submit the query to the MDNS transport.
|
||||||
for (netreq_p = req->netreqs
|
for (netreq_p = req->netreqs
|
||||||
; !r && (netreq = *netreq_p)
|
; !r && (netreq = *netreq_p)
|
||||||
|
|
14
src/mdns.c
14
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 */
|
/* TODO: treating as a timeout for now, may consider treating as error */
|
||||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
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) {
|
if (netreq->owner->user_callback) {
|
||||||
(void)_getdns_context_request_timed_out(netreq->owner);
|
(void)_getdns_context_request_timed_out(netreq->owner);
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ mdns_complete_query_from_cache_entry(
|
||||||
|
|
||||||
netreq->response_len = packet_length;
|
netreq->response_len = packet_length;
|
||||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
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);
|
_getdns_check_dns_req_complete(netreq->owner);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1016,7 +1016,7 @@ mdns_complete_query_from_cache_entry(
|
||||||
/* Fail the query? */
|
/* Fail the query? */
|
||||||
netreq->response_len = 0;
|
netreq->response_len = 0;
|
||||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
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);
|
_getdns_check_dns_req_complete(netreq->owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1026,7 +1026,7 @@ mdns_complete_query_from_cache_entry(
|
||||||
/* Failure */
|
/* Failure */
|
||||||
netreq->response_len = 0;
|
netreq->response_len = 0;
|
||||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
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);
|
_getdns_check_dns_req_complete(netreq->owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,7 +1085,7 @@ mdns_mcast_timeout_cb(void *userarg)
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
DEBUG_MDNS("%s %-35s: MSG: %p\n",
|
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,
|
msdn_cache_create_key_in_buffer(temp_key, dnsreq->name, dnsreq->name_len,
|
||||||
netreq->request_type, dnsreq->request_class);
|
netreq->request_type, dnsreq->request_class);
|
||||||
|
@ -1113,7 +1113,7 @@ mdns_mcast_timeout_cb(void *userarg)
|
||||||
/* Fail the request on timeout */
|
/* Fail the request on timeout */
|
||||||
netreq->response_len = 0;
|
netreq->response_len = 0;
|
||||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
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);
|
_getdns_check_dns_req_complete(netreq->owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1128,7 +1128,7 @@ mdns_udp_multicast_read_cb(void *userarg)
|
||||||
uint64_t current_time;
|
uint64_t current_time;
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
DEBUG_MDNS("%s %-35s: CTX: %p, NET=%d \n", MDNS_DEBUG_MREAD,
|
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();
|
current_time = _getdns_get_time_as_uintt64();
|
||||||
|
|
||||||
|
|
|
@ -938,6 +938,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
|
||||||
result->finished_next = NULL;
|
result->finished_next = NULL;
|
||||||
result->freed = NULL;
|
result->freed = NULL;
|
||||||
result->validating = 0;
|
result->validating = 0;
|
||||||
|
result->is_dns_request = 1;
|
||||||
result->chain = NULL;
|
result->chain = NULL;
|
||||||
|
|
||||||
network_req_init(result->netreqs[0], result,
|
network_req_init(result->netreqs[0], result,
|
||||||
|
|
|
@ -15,7 +15,8 @@ rm -f report.txt
|
||||||
echo "*** running out of filedescriptors (sockets) and for the"
|
echo "*** running out of filedescriptors (sockets) and for the"
|
||||||
echo "*** limit_outstanding_queries feature."
|
echo "*** limit_outstanding_queries feature."
|
||||||
echo "*** "
|
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 ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
) >> report.txt
|
) >> report.txt
|
||||||
|
@ -28,7 +29,7 @@ rm -f report.txt
|
||||||
echo "*** __FUNC__ is aliases in config.h to name to be used"
|
echo "*** __FUNC__ is aliases in config.h to name to be used"
|
||||||
echo "*** for the system with a #define"
|
echo "*** for the system with a #define"
|
||||||
echo "*** "
|
echo "*** "
|
||||||
grep '__FUNCION__' *.[ch] */*.[ch]
|
grep -n '__FUNCTION__' *.[ch] */*.[ch]
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
) >> report.txt
|
) >> report.txt
|
||||||
|
|
|
@ -313,6 +313,7 @@ typedef struct getdns_dns_req {
|
||||||
/* Internally used by return_validation_chain */
|
/* Internally used by return_validation_chain */
|
||||||
unsigned dnssec_ok_checking_disabled : 1;
|
unsigned dnssec_ok_checking_disabled : 1;
|
||||||
unsigned is_sync_request : 1;
|
unsigned is_sync_request : 1;
|
||||||
|
unsigned is_dns_request : 1;
|
||||||
|
|
||||||
/* The validating and freed variables are used to make sure a single
|
/* The validating and freed variables are used to make sure a single
|
||||||
* code path is followed while processing a DNS request, even when
|
* code path is followed while processing a DNS request, even when
|
||||||
|
|
Loading…
Reference in New Issue