Allow cleanup of naked idle timeouts

This commit is contained in:
Willem Toorop 2017-04-06 20:50:34 +02:00
parent a27915ccc9
commit c9b3e3cf7b
3 changed files with 29 additions and 9 deletions

View File

@ -2210,18 +2210,38 @@ getdns_context_set_timeout(struct getdns_context *context, uint64_t timeout)
* *
*/ */
getdns_return_t getdns_return_t
getdns_context_set_idle_timeout(struct getdns_context *context, uint64_t timeout) getdns_context_set_idle_timeout(getdns_context *context, uint64_t timeout)
{ {
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); size_t i;
/* Shuold we enforce maximum based on edns-tcp-keepalive spec? */ if (!context)
/* 0 should be allowed as that is the default.*/ return GETDNS_RETURN_INVALID_PARAMETER;
context->idle_timeout = timeout; /* Shuold we enforce maximum based on edns-tcp-keepalive spec? */
/* 0 should be allowed as that is the default.*/
dispatch_updated(context, GETDNS_CONTEXT_CODE_IDLE_TIMEOUT); context->idle_timeout = timeout;
return GETDNS_RETURN_GOOD; dispatch_updated(context, GETDNS_CONTEXT_CODE_IDLE_TIMEOUT);
if (timeout)
return GETDNS_RETURN_GOOD;
/* If timeout == 0, call scheduled idle timeout events */
for (i = 0; i < context->upstreams->count; i++) {
getdns_upstream *upstream =
&context->upstreams->upstreams[i];
if (!upstream->event.ev ||
!upstream->event.timeout_cb ||
upstream->event.read_cb ||
upstream->event.write_cb)
continue;
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
upstream->event.timeout_cb(upstream->event.userarg);
}
return GETDNS_RETURN_GOOD;
} /* getdns_context_set_timeout */ } /* getdns_context_set_timeout */

View File

@ -1717,9 +1717,8 @@ upstream_write_cb(void *userarg)
default: default:
if (netreq->owner->return_call_reporting && if (netreq->owner->return_call_reporting &&
netreq->upstream->tls_obj && netreq->upstream->tls_obj &&
netreq->debug_tls_peer_cert.data == NULL &&
(cert = SSL_get_peer_certificate(netreq->upstream->tls_obj))) { (cert = SSL_get_peer_certificate(netreq->upstream->tls_obj))) {
assert(netreq->debug_tls_peer_cert.data == NULL);
netreq->debug_tls_peer_cert.size = i2d_X509( netreq->debug_tls_peer_cert.size = i2d_X509(
cert, &netreq->debug_tls_peer_cert.data); cert, &netreq->debug_tls_peer_cert.data);
X509_free(cert); X509_free(cert);

View File

@ -1230,6 +1230,7 @@ void read_line_cb(void *userarg)
if (listen_count) if (listen_count)
(void) getdns_context_set_listen_addresses( (void) getdns_context_set_listen_addresses(
context, NULL, NULL, NULL); context, NULL, NULL, NULL);
(void) getdns_context_set_idle_timeout(context, 0);
return; return;
} }
if (query_file) if (query_file)