summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-12-10 22:34:07 +0100
committerStephen Gallagher <sgallagh@redhat.com>2009-12-15 08:33:55 -0500
commitefeff4b2d52525f35ba3c719a3432c3b390e3df2 (patch)
treee0d6801577a1eb30a3abdac8c6ff6c70ec4935c9 /server
parent796a6c947951a5a4459545b99bf97e0523f71402 (diff)
downloadsssd-efeff4b2d52525f35ba3c719a3432c3b390e3df2.tar.gz
sssd-efeff4b2d52525f35ba3c719a3432c3b390e3df2.tar.bz2
sssd-efeff4b2d52525f35ba3c719a3432c3b390e3df2.zip
fail over: Change the first server pick logic
The logic of selecting the server to fail over to was changed so that we start from the server next to the one that didn't work the last time. This is because the status of a server that failed last time might get reset before we try another one. This can cause that we try to use the nonworking server repeatedly, not giving a chance to other servers. Fixes: #321
Diffstat (limited to 'server')
-rw-r--r--server/providers/fail_over.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/server/providers/fail_over.c b/server/providers/fail_over.c
index 5c91bfc6..9795ccec 100644
--- a/server/providers/fail_over.c
+++ b/server/providers/fail_over.c
@@ -56,6 +56,7 @@ struct fo_service {
struct fo_ctx *ctx;
char *name;
struct fo_server *active_server;
+ struct fo_server *last_tried_server;
struct fo_server *server_list;
};
@@ -391,21 +392,41 @@ get_first_server_entity(struct fo_service *service, struct fo_server **_server)
server = service->active_server;
if (server != NULL) {
if (service_works(server)) {
- *_server = server;
- return EOK;
+ goto done;
}
service->active_server = NULL;
}
- /* Otherwise iterate through the server list. */
+ /*
+ * Otherwise iterate through the server list.
+ */
+
+ /* First, try servers after the last one we tried. */
+ if (service->last_tried_server != NULL) {
+ DLIST_FOR_EACH(server, service->last_tried_server->next) {
+ if (service_works(server)) {
+ goto done;
+ }
+ }
+ }
+
+ /* If none were found, try at the start. */
DLIST_FOR_EACH(server, service->server_list) {
if (service_works(server)) {
- *_server = server;
- return EOK;
+ goto done;
+ }
+ if (server == service->last_tried_server) {
+ break;
}
}
+ service->last_tried_server = NULL;
return ENOENT;
+
+done:
+ service->last_tried_server = server;
+ *_server = server;
+ return EOK;
}
static int