From 03efb66991cb234eaf724d8725b9dd90f9100ac8 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Sun, 26 Mar 2017 10:16:25 -0500 Subject: [PATCH] Keep connections open with sync requests too --- src/sync.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/sync.c b/src/sync.c index bfec94c6..75f8cca3 100644 --- a/src/sync.c +++ b/src/sync.c @@ -123,18 +123,22 @@ getdns_sync_data_cleanup(getdns_sync_data *data) * synchronous request. */ GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event); - (*upstream->event.timeout_cb)(upstream->event.userarg); - - /* This should have cleared the event */ - assert(!upstream->event.read_cb && - !upstream->event.write_cb && - !upstream->event.timeout_cb); + if (upstream->conn_state != GETDNS_CONN_OPEN || + upstream->keepalive_timeout == 0) + (*upstream->event.timeout_cb)(upstream->event.userarg); } upstream->loop = data->context->extension; upstream->is_sync_loop = 0; if (upstream->event.read_cb || upstream->event.write_cb) GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER, &upstream->event); + + else if (upstream->event.timeout_cb && + upstream->conn_state == GETDNS_CONN_OPEN && + upstream->keepalive_timeout != 0) { + GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, + upstream->keepalive_timeout, &upstream->event); + } } }