]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] proxy: add PR_O2_DISPATCH to detect dispatch mode
authorWilly Tarreau <w@1wt.eu>
Fri, 4 Mar 2011 21:44:16 +0000 (22:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Mar 2011 22:32:16 +0000 (23:32 +0100)
Till now we used the fact that the dispatch address was not null to use
the dispatch mode. This is very unconvenient, so let's have a dedicated
option.

include/types/proxy.h
src/backend.c
src/cfgparse.c

index 7a3276e2c25d74da7ca637530d676dc87f7de6ff..e724a25b43f533fcb5b8818c88ca81a3d9e4c55c 100644 (file)
 #define PR_O2_COOK_PSV  0x08000000      /* cookie ... preserve */
 
 #define PR_O2_PGSQL_CHK 0x10000000      /* use PGSQL check for server health */
+#define PR_O2_DISPATCH  0x20000000      /* use dispatch mode */
 /* end of proxy->options2 */
 
 /* bits for sticking rules */
index 0d5081a2f11500e56d58a0f311bc9d2325c19612..857496c5ce618371d4d721ba33b6d308f834221f 100644 (file)
@@ -619,8 +619,7 @@ int assign_server(struct session *s)
                        goto out;
                }
        }
-       else if (!*(int *)&s->be->dispatch_addr.sin_addr &&
-                !(s->be->options & PR_O_TRANSP)) {
+       else if (!(s->be->options2 & PR_O2_DISPATCH) && !(s->be->options & PR_O_TRANSP)) {
                err = SRV_STATUS_NOSRV;
                goto out;
        }
@@ -700,7 +699,7 @@ int assign_server_address(struct session *s)
                        }
                }
        }
-       else if (*(int *)&s->be->dispatch_addr.sin_addr) {
+       else if (s->be->options2 & PR_O2_DISPATCH) {
                /* connect to the defined dispatch addr */
                s->req->cons->addr.s.to = s->be->dispatch_addr;
        }
index aae2efeda193273f17d61115799a818e97ef918b..8c23f9460948bef04e580443c6f19dd82b23ee81 100644 (file)
@@ -3864,6 +3864,7 @@ stats_error_parsing:
                        goto out;
                }
                curproxy->dispatch_addr = *sk;
+               curproxy->options2 |= PR_O2_DISPATCH;
        }
        else if (!strcmp(args[0], "balance")) {  /* set balancing with optional algorithm */
                if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL))
@@ -5618,14 +5619,14 @@ int check_config_validity()
                                        cfgerr++;
                                }
 #endif
-                               else if (*(int *)&curproxy->dispatch_addr.sin_addr != 0) {
+                               else if (curproxy->options2 & PR_O2_DISPATCH) {
                                        Warning("config : dispatch address of %s '%s' will be ignored in balance mode.\n",
                                                proxy_type_str(curproxy), curproxy->id);
                                        err_code |= ERR_WARN;
                                }
                        }
                        else if (!(curproxy->options & (PR_O_TRANSP | PR_O_HTTP_PROXY)) &&
-                                (*(int *)&curproxy->dispatch_addr.sin_addr == 0)) {
+                                !(curproxy->options2 & PR_O2_DISPATCH)) {
                                /* If no LB algo is set in a backend, and we're not in
                                 * transparent mode, dispatch mode nor proxy mode, we
                                 * want to use balance roundrobin by default.