diff --git a/src/context.c b/src/context.c index 2e26b06c..5396fcc4 100644 --- a/src/context.c +++ b/src/context.c @@ -2210,18 +2210,38 @@ getdns_context_set_timeout(struct getdns_context *context, uint64_t timeout) * */ 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? */ - /* 0 should be allowed as that is the default.*/ + if (!context) + 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 */ diff --git a/src/stub.c b/src/stub.c index e8a8ee52..3597cb88 100644 --- a/src/stub.c +++ b/src/stub.c @@ -1717,9 +1717,8 @@ upstream_write_cb(void *userarg) default: if (netreq->owner->return_call_reporting && netreq->upstream->tls_obj && + netreq->debug_tls_peer_cert.data == NULL && (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( cert, &netreq->debug_tls_peer_cert.data); X509_free(cert); diff --git a/src/tools/getdns_query.c b/src/tools/getdns_query.c index 5a431484..7dca01fe 100644 --- a/src/tools/getdns_query.c +++ b/src/tools/getdns_query.c @@ -1230,6 +1230,7 @@ void read_line_cb(void *userarg) if (listen_count) (void) getdns_context_set_listen_addresses( context, NULL, NULL, NULL); + (void) getdns_context_set_idle_timeout(context, 0); return; } if (query_file)