]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] cleaned up the check_addr patch a bit
authorWilly Tarreau <w@1wt.eu>
Sun, 25 Mar 2007 18:46:19 +0000 (20:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 25 Mar 2007 18:46:19 +0000 (20:46 +0200)
removed useless set_check_addr entry and rely on check_addr itself.

include/types/server.h
src/cfgparse.c
src/checks.c

index 89c123d952a581c64e6818b6768835147437212d..6e94c7dd95548342fc055bb1239d3b4ccfe11a37 100644 (file)
@@ -68,8 +68,7 @@ struct server {
 #ifdef CONFIG_HAP_CTTPROXY
        struct sockaddr_in tproxy_addr; /* non-local address we want to bind to for connect() */
 #endif
-       struct sockaddr_in check_addr;
-       int set_check_addr ;
+       struct sockaddr_in check_addr;          /* the address to check, if different from <addr> */
        short check_port;                       /* the port to use for the health checks */
        int health;                             /* 0->rise-1 = bad; rise->rise+fall-1 = good */
        int rise, fall;                 /* time in iterations */
index ff1c927cb45c3facfcba7d8241189524ae9a8084..cfb2e7e00a783e7f50c4ae9f611964903f7fc41f 100644 (file)
@@ -1197,7 +1197,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                newsrv->rise = DEF_RISETIME;
                newsrv->fall = DEF_FALLTIME;
                newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
-               newsrv->set_check_addr = 0;
+
                cur_arg = 3;
                while (*args[cur_arg]) {
                        if (!strcmp(args[cur_arg], "cookie")) {
@@ -1220,7 +1220,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                        }
                        else if (!strcmp(args[cur_arg], "addr")) {
                                newsrv->check_addr = *str2sa(args[cur_arg + 1]);
-                               newsrv->set_check_addr = 1;
                                cur_arg += 2;
                        }
                        else if (!strcmp(args[cur_arg], "port")) {
@@ -1306,13 +1305,16 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
                        }
 #endif
                        else {
-                               Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'check', 'inter', 'rise', 'fall', 'port', 'source', 'minconn', 'maxconn' and 'weight'.\n",
+                               Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'check', 'inter', 'rise', 'fall', 'addr', 'port', 'source', 'minconn', 'maxconn' and 'weight'.\n",
                                      file, linenum, newsrv->id);
                                return -1;
                        }
                }
 
                if (do_check) {
+                       if (!newsrv->check_port && newsrv->check_addr.sin_port)
+                               newsrv->check_port = newsrv->check_addr.sin_port;
+
                        if (!newsrv->check_port && !(newsrv->state & SRV_MAPPORTS))
                                newsrv->check_port = realport; /* by default */
                        if (!newsrv->check_port) {
index 295be1527d34673760fa5c73315633e2089b4dc8..1e72743f9cccb16bb3f1ea3c024ce9488dc14400 100644 (file)
@@ -249,16 +249,13 @@ int process_chk(struct task *t)
                                //fprintf(stderr, "process_chk: 3\n");
 
                                
-                                if ( s->set_check_addr == 1 )
-                               {
-                               /* we'll connect to the check addr specified on the server */
+                               if (s->check_addr.sin_addr.s_addr)
+                                       /* we'll connect to the check addr specified on the server */
                                        sa = s->check_addr;
-                               }
                                else
-                               {
-                               /* we'll connect to the addr on the server */
+                                       /* we'll connect to the addr on the server */
                                        sa = s->addr;
-                               }
+
                                /* we'll connect to the check port on the server */
                                sa.sin_port = htons(s->check_port);