From d25e7c659361ebd794ef011dc9305543f266e8c4 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 12 Sep 2012 19:23:48 +0200 Subject: FO: Check server validity before setting status The list of resolved servers is allocated on the back end context and kept in the fo_service structure. However, a single request often resolves a server and keeps a pointer until the end of a request and only then gives feedback about the server based on the request result. This presents a big race condition in case the SRV resolution is used. When there are requests coming in in parallel, it is possible that an incoming request will invalidate a server until another request that holds a pointer to the original server is able to give a feedback. This patch simply checks if a server is in the list of servers maintained by a service before reading its status. https://fedorahosted.org/sssd/ticket/1364 --- src/providers/fail_over.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/providers/fail_over.c') diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 422cd675..d776037a 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -1564,10 +1564,13 @@ void fo_reset_services(struct fo_ctx *fo_ctx) } } -struct fo_service * -fo_get_server_service(struct fo_server *server) +bool fo_svc_has_server(struct fo_service *service, struct fo_server *server) { - if (!server) return NULL; - return server->service; -} + struct fo_server *srv; + + DLIST_FOR_EACH(srv, service->server_list) { + if (srv == server) return true; + } + return false; +} -- cgit