{
struct http_client_queue *const *queue_idx;
- if (host->dns_lookup != NULL)
+ if (host->dns_lookup != NULL && host->client->set.dns_client == NULL)
dns_lookup_switch_ioloop(host->dns_lookup);
array_foreach(&host->queues, queue_idx)
http_client_queue_switch_ioloop(*queue_idx);
client->ioloop = io_loop_create();
http_client_switch_ioloop(client);
+ if (client->set.dns_client != NULL)
+ dns_client_switch_ioloop(client->set.dns_client);
/* either we're waiting for network I/O or we're getting out of a
callback using timeout_add_short(0) */
i_assert(io_loop_have_ios(client->ioloop) ||
io_loop_set_current(prev_ioloop);
http_client_switch_ioloop(client);
+ if (client->set.dns_client != NULL)
+ dns_client_switch_ioloop(client->set.dns_client);
io_loop_set_current(client->ioloop);
io_loop_destroy(&client->ioloop);
}
#include "write-full.h"
#include "http-url.h"
#include "http-client.h"
+#include "dns-lookup.h"
struct http_test_request {
struct io *io;
int main(int argc, char *argv[])
{
+ struct dns_client *dns_client;
+ struct dns_lookup_settings dns_set;
struct http_client_settings http_set;
struct http_client *http_client;
+ const char *error;
struct ioloop *ioloop;
+ lib_init();
+
+ ioloop = io_loop_create();
+ io_loop_set_running(ioloop);
+
+
+ memset(&dns_set, 0, sizeof(dns_set));
+ dns_set.dns_client_socket_path = "/var/run/dovecot/dns-client";
+ dns_set.timeout_msecs = 30*1000;
+ dns_set.idle_timeout_msecs = UINT_MAX;
+ dns_client = dns_client_init(&dns_set);
+
+ if (dns_client_connect(dns_client, &error) < 0)
+ i_fatal("Couldn't initialize DNS client: %s", error);
+
memset(&http_set, 0, sizeof(http_set));
- http_set.dns_client_socket_path = "/var/run/dovecot/dns-client";
+ http_set.dns_client = dns_client;
http_set.ssl_allow_invalid_cert = TRUE;
http_set.ssl_ca_dir = "/etc/ssl/certs"; /* debian */
http_set.ssl_ca_file = "/etc/pki/tls/cert.pem"; /* redhat */
http_set.debug = TRUE;
http_set.rawlog_dir = "/tmp/http-test";
- lib_init();
-
- ioloop = io_loop_create();
- io_loop_set_running(ioloop);
-
http_client = http_client_init(&http_set);
switch (argc) {
http_client_wait(http_client);
http_client_deinit(&http_client);
+ dns_client_deinit(&dns_client);
+
io_loop_destroy(&ioloop);
lib_deinit();
}