summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-01-13 14:13:14 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-01-14 09:00:08 -0500
commit815db657bea77807798aebd782cfa69eb73b3b38 (patch)
tree802590678a9a8a36e7fba2bae076aaa18ebfdebf /server
parent71585aa7e7cfb414530dc41783669a1566099890 (diff)
downloadsssd-815db657bea77807798aebd782cfa69eb73b3b38.tar.gz
sssd-815db657bea77807798aebd782cfa69eb73b3b38.tar.bz2
sssd-815db657bea77807798aebd782cfa69eb73b3b38.zip
Explicitly set async DNS timeout
We will allow 5s per DNS server, no retries.
Diffstat (limited to 'server')
-rw-r--r--server/providers/data_provider_fo.c2
-rw-r--r--server/resolv/async_resolv.c13
-rw-r--r--server/resolv/async_resolv.h2
-rw-r--r--server/tests/fail_over-tests.c2
-rw-r--r--server/tests/resolv-tests.c2
5 files changed, 15 insertions, 6 deletions
diff --git a/server/providers/data_provider_fo.c b/server/providers/data_provider_fo.c
index 23c857aa..7d024048 100644
--- a/server/providers/data_provider_fo.c
+++ b/server/providers/data_provider_fo.c
@@ -66,7 +66,7 @@ int be_init_failover(struct be_ctx *ctx)
return ENOMEM;
}
- ret = resolv_init(ctx, ctx->ev, &ctx->be_fo->resolv);
+ ret = resolv_init(ctx, ctx->ev, 5, &ctx->be_fo->resolv);
if (ret != EOK) {
talloc_zfree(ctx->be_fo);
return ret;
diff --git a/server/resolv/async_resolv.c b/server/resolv/async_resolv.c
index c350d6c3..8455b575 100644
--- a/server/resolv/async_resolv.c
+++ b/server/resolv/async_resolv.c
@@ -72,6 +72,9 @@ struct resolv_ctx {
ares_channel channel;
/* List of file descriptors that are watched by tevent. */
struct fd_watch *fds;
+
+ /* Time in milliseconds before canceling a DNS request */
+ int timeout;
};
struct resolv_ctx *context_list;
@@ -242,7 +245,12 @@ recreate_ares_channel(struct resolv_ctx *ctx)
*/
options.sock_state_cb = fd_event;
options.sock_state_cb_data = ctx;
- ret = ares_init_options(&new_channel, &options, ARES_OPT_SOCK_STATE_CB);
+ options.timeout = ctx->timeout * 1000;
+ options.tries = 1;
+ ret = ares_init_options(&new_channel, &options,
+ ARES_OPT_SOCK_STATE_CB |
+ ARES_OPT_TIMEOUTMS |
+ ARES_OPT_TRIES);
if (ret != ARES_SUCCESS) {
DEBUG(1, ("Failed to initialize ares channel: %s\n",
resolv_strerror(ret)));
@@ -261,7 +269,7 @@ recreate_ares_channel(struct resolv_ctx *ctx)
int
resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
- struct resolv_ctx **ctxp)
+ int timeout, struct resolv_ctx **ctxp)
{
int ret;
struct resolv_ctx *ctx;
@@ -271,6 +279,7 @@ resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
return ENOMEM;
ctx->ev_ctx = ev_ctx;
+ ctx->timeout = timeout;
ret = recreate_ares_channel(ctx);
if (ret != EOK) {
diff --git a/server/resolv/async_resolv.h b/server/resolv/async_resolv.h
index e0515383..5558e15c 100644
--- a/server/resolv/async_resolv.h
+++ b/server/resolv/async_resolv.h
@@ -47,7 +47,7 @@
struct resolv_ctx;
int resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
- struct resolv_ctx **ctxp);
+ int timeout, struct resolv_ctx **ctxp);
void resolv_reread_configuration(void);
diff --git a/server/tests/fail_over-tests.c b/server/tests/fail_over-tests.c
index 16cc60e3..c3e9dfe5 100644
--- a/server/tests/fail_over-tests.c
+++ b/server/tests/fail_over-tests.c
@@ -71,7 +71,7 @@ setup_test(void)
fail("Could not init tevent context");
}
- ret = resolv_init(ctx, ctx->ev, &ctx->resolv);
+ ret = resolv_init(ctx, ctx->ev, 5, &ctx->resolv);
if (ret != EOK) {
talloc_free(ctx);
fail("Could not init resolv context");
diff --git a/server/tests/resolv-tests.c b/server/tests/resolv-tests.c
index d6b8c4f3..0c18dfdc 100644
--- a/server/tests/resolv-tests.c
+++ b/server/tests/resolv-tests.c
@@ -73,7 +73,7 @@ static int setup_resolv_test(struct resolv_test_ctx **ctx)
return EFAULT;
}
- ret = resolv_init(test_ctx, test_ctx->ev, &test_ctx->resolv);
+ ret = resolv_init(test_ctx, test_ctx->ev, 5, &test_ctx->resolv);
if (ret != EOK) {
fail("Could not init resolv context");
talloc_free(test_ctx);