summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/providers/fail_over.c19
-rw-r--r--server/resolv/async_resolv.c15
-rw-r--r--server/resolv/async_resolv.h4
-rw-r--r--server/tests/resolv-tests.c10
4 files changed, 28 insertions, 20 deletions
diff --git a/server/providers/fail_over.c b/server/providers/fail_over.c
index ce94ac30..796fc900 100644
--- a/server/providers/fail_over.c
+++ b/server/providers/fail_over.c
@@ -456,16 +456,18 @@ fo_resolve_service_done(struct tevent_req *subreq)
int resolv_status;
struct resolve_service_request *request;
struct server_common *common;
+ int ret;
common = tevent_req_callback_data(subreq, struct server_common);
- if (common->hostent != NULL)
- talloc_free(common->hostent);
- resolv_gethostbyname_recv(common, subreq, &resolv_status, NULL,
- &common->hostent);
- talloc_free(subreq);
+ if (common->hostent != NULL) {
+ talloc_zfree(common->hostent);
+ }
- if (common->hostent == NULL) {
+ ret = resolv_gethostbyname_recv(subreq, common,
+ &resolv_status, NULL, &common->hostent);
+ talloc_free(subreq);
+ if (ret != EOK) {
DEBUG(1, ("Failed to resolve %s: %s\n", common->name,
resolv_strerror(resolv_status)));
}
@@ -473,10 +475,11 @@ fo_resolve_service_done(struct tevent_req *subreq)
/* Take care of all requests for this server. */
while ((request = common->request_list) != NULL) {
DLIST_REMOVE(common->request_list, request);
- if (resolv_status)
+ if (resolv_status) {
tevent_req_error(request->req, resolv_status);
- else
+ } else {
tevent_req_done(request->req);
+ }
}
}
diff --git a/server/resolv/async_resolv.c b/server/resolv/async_resolv.c
index f567a398..f6ed2028 100644
--- a/server/resolv/async_resolv.c
+++ b/server/resolv/async_resolv.c
@@ -395,25 +395,28 @@ resolv_gethostbyname_done(void *arg, int status, int timeouts, struct hostent *h
}
int
-resolv_gethostbyname_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req,
+resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
int *status, int *timeouts,
struct hostent **hostent)
{
struct gethostbyname_state *state = tevent_req_data(req, struct gethostbyname_state);
enum tevent_req_state tstate;
- uint64_t err;
+ uint64_t err = EIO;
/* Fill in even in case of error as status contains the
* c-ares return code */
- if (status)
+ if (status) {
*status = state->status;
- if (timeouts)
+ }
+ if (timeouts) {
*timeouts = state->timeouts;
- if (hostent)
+ }
+ if (hostent) {
*hostent = talloc_steal(mem_ctx, state->hostent);
+ }
if (tevent_req_is_error(req, &tstate, &err)) {
- return -1;
+ return err;
}
return EOK;
diff --git a/server/resolv/async_resolv.h b/server/resolv/async_resolv.h
index fcea6b85..702d4dd7 100644
--- a/server/resolv/async_resolv.h
+++ b/server/resolv/async_resolv.h
@@ -61,8 +61,8 @@ struct tevent_req *resolv_gethostbyname_send(TALLOC_CTX *mem_ctx,
const char *name,
int family);
-int resolv_gethostbyname_recv(TALLOC_CTX *mem_ctx,
- struct tevent_req *req,
+int resolv_gethostbyname_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
int *status,
int *timeouts,
struct hostent **hostent);
diff --git a/server/tests/resolv-tests.c b/server/tests/resolv-tests.c
index 71a49310..ea1ac9fb 100644
--- a/server/tests/resolv-tests.c
+++ b/server/tests/resolv-tests.c
@@ -141,7 +141,8 @@ static void test_localhost(struct tevent_req *req)
test_ctx->done = true;
- recv_status = resolv_gethostbyname_recv(test_ctx, req, &status, NULL, &hostent);
+ recv_status = resolv_gethostbyname_recv(req, test_ctx,
+ &status, NULL, &hostent);
talloc_zfree(req);
if (recv_status != EOK) {
DEBUG(2, ("resolv_gethostbyname_recv failed: %d\n", recv_status));
@@ -205,7 +206,8 @@ static void test_negative(struct tevent_req *req)
test_ctx = tevent_req_callback_data(req, struct resolv_test_ctx);
test_ctx->done = true;
- recv_status = resolv_gethostbyname_recv(test_ctx, req, &status, NULL, &hostent);
+ recv_status = resolv_gethostbyname_recv(req, test_ctx,
+ &status, NULL, &hostent);
talloc_zfree(req);
if (recv_status == EOK) {
DEBUG(7, ("resolv_gethostbyname_recv succeeded in a negative test"));
@@ -270,8 +272,8 @@ static void test_internet(struct tevent_req *req)
switch (test_ctx->tested_function) {
case TESTING_HOSTNAME:
- recv_status = resolv_gethostbyname_recv(tmp_ctx, req, &status, NULL,
- &hostent);
+ recv_status = resolv_gethostbyname_recv(req, tmp_ctx,
+ &status, NULL, &hostent);
test_ctx->error = (hostent->h_length == 0) ? ENOENT : EOK;
break;
case TESTING_TXT: