#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 */
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")) {
}
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")) {
}
#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) {
//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);