summaryrefslogtreecommitdiff
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-20 08:56:00 -0500
commitb8c8639a95511e602ce5268dc8a63cf76cbf1d82 (patch)
treec09fd6f8157511a2efdff6c3734b9c904463ecf1 /server
parent02aeb3609eb8325bc8e8ba7b63c7465c9a8471f5 (diff)
downloadsssd-b8c8639a95511e602ce5268dc8a63cf76cbf1d82.tar.gz
sssd-b8c8639a95511e602ce5268dc8a63cf76cbf1d82.tar.bz2
sssd-b8c8639a95511e602ce5268dc8a63cf76cbf1d82.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 0be79185..ce92c8a7 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