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:09:44 -0500 |
commit | 89648ee8c27f91b178c6eda3dadec854bd631cb9 (patch) | |
tree | 3ff182e52085c2f5324b4a9297c411e79c3a014b /server/resolv | |
parent | a3292cb6f06ac6ba9a9bdeb9a080751b3635a3ec (diff) | |
download | sssd-89648ee8c27f91b178c6eda3dadec854bd631cb9.tar.gz sssd-89648ee8c27f91b178c6eda3dadec854bd631cb9.tar.xz sssd-89648ee8c27f91b178c6eda3dadec854bd631cb9.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 c350d6c36..8455b575e 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 e0515383b..5558e15c6 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); |