]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
While fixing the backup server round-robin "feature", a new bug was introduced
authorwilly tarreau <willy@wtap.(none)>
Thu, 23 Mar 2006 10:27:02 +0000 (11:27 +0100)
committerwilly tarreau <willy@wtap.(none)>
Thu, 23 Mar 2006 10:27:02 +0000 (11:27 +0100)
which could miss some backup servers.

haproxy.c

index 67dce3dd3d70305fb547bb09ce469aaa8ffc634f..d03ec1f4e449f495df566eeb6a8ad22f5120b89d 100644 (file)
--- a/haproxy.c
+++ b/haproxy.c
@@ -1787,17 +1787,21 @@ static inline void session_free(struct session *s) {
  */
 static inline struct server *find_server(struct proxy *px) {
     struct server *srv = px->cursrv;
+    struct server *end;
     int ignore_backup = 1;
 
     do {
+       if (srv == NULL)
+           srv = px->srv;
+        end = srv;
        do  {
-           if (srv == NULL)
-               srv = px->srv;
            if (srv->state & SRV_RUNNING
                && !((srv->state & SRV_BACKUP) && ignore_backup))
                return srv;
            srv = srv->next;
-       } while (srv != px->cursrv);
+           if (srv == NULL)
+               srv = px->srv;
+       } while (srv != end);
 
        /* By default, we look for the first backup server if all others are
         * DOWN. But in some cases, it may be desirable to load-balance across