diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2015-09-21 12:31:38 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-09-22 23:35:52 +0200 |
commit | 63de05590cd0a9c1319880f44c6c1557e272d249 (patch) | |
tree | c12ea3d9991a1e3956e174d79ac2886ad96a4574 /src | |
parent | 63c31bbd54f92a90f82f1a9db09b3b4ac2e7cb4a (diff) | |
download | sssd-63de05590cd0a9c1319880f44c6c1557e272d249.tar.gz sssd-63de05590cd0a9c1319880f44c6c1557e272d249.tar.xz sssd-63de05590cd0a9c1319880f44c6c1557e272d249.zip |
FO: Also reset the server common data in addition to SRV
In a server that is expanded from a SRV query was reset, only it's
'meta-server' status was set to neutral, but the server->common
structure still retained its not_working status.
This patch also resets the status of the common structure so that both
the SRV query and resolving the server are retried next time.
Diffstat (limited to 'src')
-rw-r--r-- | src/providers/fail_over.c | 4 | ||||
-rw-r--r-- | src/tests/cmocka/test_fo_srv.c | 44 |
2 files changed, 42 insertions, 6 deletions
diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 562f0b3fd..b076687ac 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -1554,7 +1554,9 @@ void fo_reset_servers(struct fo_service *service) DLIST_FOR_EACH(server, service->server_list) { if (server->srv_data != NULL) { set_srv_data_status(server->srv_data, SRV_NEUTRAL); - } else { + } + + if (server->common) { fo_set_server_status(server, SERVER_NAME_NOT_RESOLVED); } diff --git a/src/tests/cmocka/test_fo_srv.c b/src/tests/cmocka/test_fo_srv.c index e5c5e4fe3..953f8b48b 100644 --- a/src/tests/cmocka/test_fo_srv.c +++ b/src/tests/cmocka/test_fo_srv.c @@ -292,13 +292,10 @@ static void test_fo_srv_done1(struct tevent_req *req); static void test_fo_srv_done2(struct tevent_req *req); static void test_fo_srv_done3(struct tevent_req *req); static void test_fo_srv_done4(struct tevent_req *req); +static void test_fo_srv_done5(struct tevent_req *req); -void test_fo_srv(void **state) +static void test_fo_srv_mock_dns(struct test_fo_srv_ctx *test_ctx) { - errno_t ret; - struct tevent_req *req; - struct test_fo_srv_ctx *test_ctx = - talloc_get_type(*state, struct test_fo_srv_ctx); struct ares_srv_reply *s1; struct ares_srv_reply *s2; char *dns_domain; @@ -325,6 +322,16 @@ void test_fo_srv(void **state) assert_non_null(dns_domain); mock_srv_results(s1, TEST_SRV_TTL, dns_domain); +} + +static void test_fo_srv(void **state) +{ + errno_t ret; + struct tevent_req *req; + struct test_fo_srv_ctx *test_ctx = + talloc_get_type(*state, struct test_fo_srv_ctx); + + test_fo_srv_mock_dns(test_ctx); ret = fo_add_srv_server(test_ctx->fo_svc, "_ldap", "sssd.com", "sssd.local", "tcp", test_ctx); @@ -425,6 +432,33 @@ static void test_fo_srv_done4(struct tevent_req *req) /* No servers are left..*/ assert_int_equal(ret, ENOENT); + /* reset the server status and try again.. */ + fo_reset_servers(test_ctx->fo_svc); + test_fo_srv_mock_dns(test_ctx); + + req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev, + test_ctx->resolv, test_ctx->fo_ctx, + test_ctx->fo_svc); + assert_non_null(req); + tevent_req_set_callback(req, test_fo_srv_done5, test_ctx); +} + +static void test_fo_srv_done5(struct tevent_req *req) +{ + struct test_fo_srv_ctx *test_ctx = \ + tevent_req_callback_data(req, struct test_fo_srv_ctx); + struct fo_server *srv; + errno_t ret; + + ret = fo_resolve_service_recv(req, &srv); + talloc_zfree(req); + + assert_int_equal(ret, ERR_OK); + + /* ldap1.sssd.com has lower priority, it must always be first */ + check_server(srv, 389, "ldap1.sssd.com"); + + /* OK, we made a full circle with the test, done */ test_ctx->ctx->error = ERR_OK; test_ctx->ctx->done = true; } |