diff --git a/include/types/server.h b/include/types/server.h index 89c123d95..6e94c7dd9 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -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 */ 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 */ diff --git a/src/cfgparse.c b/src/cfgparse.c index ff1c927cb..cfb2e7e00 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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) { diff --git a/src/checks.c b/src/checks.c index 295be1527..1e72743f9 100644 --- a/src/checks.c +++ b/src/checks.c @@ -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);