Skip to content

Commit

Permalink
lib-dns: Move calling callback to separate function
Browse files Browse the repository at this point in the history
Simplifies next commit
  • Loading branch information
cmouse committed Aug 24, 2018
1 parent 107a201 commit 5ee1bd7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib-dns/dns-lookup.c
Expand Up @@ -57,6 +57,14 @@ struct dns_client {

static void dns_lookup_free(struct dns_lookup **_lookup);

static void dns_lookup_save_msecs(struct dns_lookup *lookup);

static void dns_lookup_callback(struct dns_lookup *lookup)
{
dns_lookup_save_msecs(lookup);
lookup->callback(&lookup->result, lookup->context);
}

static void dns_client_disconnect(struct dns_client *client, const char *error)
{
struct dns_lookup *lookup, *next;
Expand All @@ -76,7 +84,7 @@ static void dns_client_disconnect(struct dns_client *client, const char *error)
client->head = NULL;
while (lookup != NULL) {
next = lookup->next;
lookup->callback(&result, lookup->context);
dns_lookup_callback(lookup);
dns_lookup_free(&lookup);
lookup = next;
}
Expand Down Expand Up @@ -163,8 +171,7 @@ static int dns_client_input_args(struct connection *conn, const char *const *arg
"Invalid input from %s", conn->name));
return -1;
} else if (ret > 0) {
dns_lookup_save_msecs(lookup);
lookup->callback(&lookup->result, lookup->context);
dns_lookup_callback(lookup);
retry = !lookup->client->deinit_client_at_free;
dns_lookup_free(&lookup);
}
Expand All @@ -176,7 +183,7 @@ static void dns_lookup_timeout(struct dns_lookup *lookup)
{
lookup->result.error = "DNS lookup timed out";

lookup->callback(&lookup->result, lookup->context);
dns_lookup_callback(lookup);
dns_lookup_free(&lookup);
}

Expand Down Expand Up @@ -375,7 +382,7 @@ dns_client_lookup_common(struct dns_client *client,
&lookup->result.error);
}
if (ret <= 0) {
callback(&lookup.result, context);
dns_lookup_callback(lookup);
return -1;
}
}
Expand Down

0 comments on commit 5ee1bd7

Please sign in to comment.