summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-01-18 12:35:10 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-01-22 09:14:04 -0500
commite9c397b21d4ab29e5f691f20ab045cb72109c781 (patch)
tree579dc6e007e2765dc160271f6dde2301a0cb1ba7 /server
parentf464891b10f73c5dff4f769774635483d9a7f7f8 (diff)
downloadsssd-e9c397b21d4ab29e5f691f20ab045cb72109c781.tar.gz
sssd-e9c397b21d4ab29e5f691f20ab045cb72109c781.tar.xz
sssd-e9c397b21d4ab29e5f691f20ab045cb72109c781.zip
Fix timeout memory heirarchy
This fixes two issues: 1) Eliminates a double-free when a timeout occurs (we were freeing the running event context) 2) Ensures that we don't continue to schedule unnecessary timeout checks
Diffstat (limited to 'server')
-rw-r--r--server/resolv/async_resolv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/server/resolv/async_resolv.c b/server/resolv/async_resolv.c
index 0be791851..ce92c8a7d 100644
--- a/server/resolv/async_resolv.c
+++ b/server/resolv/async_resolv.c
@@ -160,11 +160,23 @@ static void
check_fd_timeouts(struct tevent_context *ev, struct tevent_timer *te,
struct timeval current_time, void *private_data)
{
- struct resolv_ctx *ctx = private_data;
+ struct resolv_ctx *ctx = talloc_get_type(private_data, struct resolv_ctx);
DEBUG(9, ("Checking for DNS timeouts\n"));
+
+ /* NULLify the timeout_watcher so we don't
+ * free it in the _done() function if it
+ * gets called. Now that we're already in
+ * the handler, tevent will take care of
+ * freeing it when it returns.
+ */
+ ctx->timeout_watcher = NULL;
+
ares_process_fd(ctx->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD);
- add_timeout_timer(ev, ctx);
+
+ if (ctx->pending_requests > 0) {
+ add_timeout_timer(ev, ctx);
+ }
}
static void