projects
/
freeradius.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
05cd3af
)
Make other balance types work
author
Alan T. DeKok
<aland@freeradius.org>
Fri, 10 Apr 2009 14:12:18 +0000
(16:12 +0200)
committer
Alan T. DeKok
<aland@freeradius.org>
Fri, 10 Apr 2009 14:12:18 +0000
(16:12 +0200)
src/main/realms.c
patch
|
blob
|
history
diff --git
a/src/main/realms.c
b/src/main/realms.c
index
5227291
..
406bf55
100644
(file)
--- a/
src/main/realms.c
+++ b/
src/main/realms.c
@@
-1825,11
+1825,14
@@
home_server *home_server_ldb(const char *realmname,
/* FALL-THROUGH */
case HOME_POOL_LOAD_BALANCE:
/* FALL-THROUGH */
case HOME_POOL_LOAD_BALANCE:
- found = pool->servers[0];
+ case HOME_POOL_FAIL_OVER:
+ start = 0;
+ break;
- default:
+ default:
/* this shouldn't happen... */
start = 0;
break;
start = 0;
break;
+
}
/*
}
/*
@@
-1842,6
+1845,8
@@
home_server *home_server_ldb(const char *realmname,
for (count = 0; count < pool->num_home_servers; count++) {
home_server *home = pool->servers[(start + count) % pool->num_home_servers];
for (count = 0; count < pool->num_home_servers; count++) {
home_server *home = pool->servers[(start + count) % pool->num_home_servers];
+ if (!home) continue;
+
if (home->state == HOME_STATE_IS_DEAD) {
continue;
}
if (home->state == HOME_STATE_IS_DEAD) {
continue;
}
@@
-1866,11
+1871,18
@@
home_server *home_server_ldb(const char *realmname,
}
#endif
}
#endif
- if (pool->type != HOME_POOL_LOAD_BALANCE) {
+ /*
+ * We've found the first "live" one. Use that.
+ */
+ if (pool->type == HOME_POOL_FAIL_OVER) {
found = home;
break;
}
found = home;
break;
}
+ /*
+ * Otherwise we're doing some kind of load balancing.
+ * If we haven't found one yet, pick this one.
+ */
if (!found) {
found = home;
continue;
if (!found) {
found = home;
continue;
@@
-1882,7
+1894,7
@@
home_server *home_server_ldb(const char *realmname,
/*
* Prefer this server if it's less busy than the
/*
* Prefer this server if it's less busy than the
- * one we previously found.
+ * one we
had
previously found.
*/
if (home->currently_outstanding < found->currently_outstanding) {
RDEBUG3("PROXY Choosing %s: It's less busy than %s",
*/
if (home->currently_outstanding < found->currently_outstanding) {
RDEBUG3("PROXY Choosing %s: It's less busy than %s",
@@
-1908,7
+1920,6
@@
home_server *home_server_ldb(const char *realmname,
if (((count + 1) * (fr_rand() & 0xffff)) < (uint32_t) 0x10000) {
found = home;
}
if (((count + 1) * (fr_rand() & 0xffff)) < (uint32_t) 0x10000) {
found = home;
}
-
} /* loop over the home servers */
/*
} /* loop over the home servers */
/*
@@
-1992,6
+2003,8
@@
home_server *home_server_ldb(const char *realmname,
for (count = 0; count < pool->num_home_servers; count++) {
home_server *home = pool->servers[count];
for (count = 0; count < pool->num_home_servers; count++) {
home_server *home = pool->servers[count];
+ if (!home) continue;
+
if ((home->state == HOME_STATE_IS_DEAD) &&
(home->ping_check == HOME_PING_CHECK_NONE)) {
home->state = HOME_STATE_ALIVE;
if ((home->state == HOME_STATE_IS_DEAD) &&
(home->ping_check == HOME_PING_CHECK_NONE)) {
home->state = HOME_STATE_ALIVE;