Skip to content

Commit

Permalink
lib-dns: Always allocate lookup
Browse files Browse the repository at this point in the history
Simplifies next change
  • Loading branch information
cmouse committed Aug 27, 2018
1 parent 10e8716 commit c755b83
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib-dns/dns-lookup.c
Expand Up @@ -371,14 +371,15 @@ dns_client_lookup_common(struct dns_client *client,
dns_lookup_callback_t *callback, void *context,
struct dns_lookup **lookup_r)
{
struct dns_lookup tlookup, *lookup;
struct dns_lookup *lookup;
int ret;

i_assert(param != NULL && *param != '\0');
cmd = t_strdup_printf("%s\t%s\n", cmd, param);

i_zero(&tlookup);
lookup = &tlookup;
pool_t pool = pool_alloconly_create("dns lookup", 512);
lookup = p_new(pool, struct dns_lookup, 1);
lookup->pool = pool;

if (gettimeofday(&lookup->start_time, NULL) < 0)
i_fatal("gettimeofday() failed: %m");
Expand All @@ -403,14 +404,11 @@ dns_client_lookup_common(struct dns_client *client,
}
if (ret <= 0) {
dns_lookup_callback(lookup);
pool_unref(&lookup->pool);
return -1;
}
}

pool_t pool = pool_alloconly_create("dns lookup", 512);
lookup = p_new(pool, struct dns_lookup, 1);
lookup->pool = pool;
*lookup = tlookup;
if (client->timeout_msecs != 0) {
lookup->to = timeout_add_to(client->ioloop,
client->timeout_msecs,
Expand Down

0 comments on commit c755b83

Please sign in to comment.