diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-01-13 14:13:14 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-01-14 09:00:08 -0500 |
commit | 815db657bea77807798aebd782cfa69eb73b3b38 (patch) | |
tree | 802590678a9a8a36e7fba2bae076aaa18ebfdebf /server/resolv | |
parent | 71585aa7e7cfb414530dc41783669a1566099890 (diff) | |
download | sssd-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/resolv')
-rw-r--r-- | server/resolv/async_resolv.c | 13 | ||||
-rw-r--r-- | server/resolv/async_resolv.h | 2 |
2 files changed, 12 insertions, 3 deletions
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); |