]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] server check intervals must not be null
authorWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 17:58:32 +0000 (18:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 17:58:32 +0000 (18:58 +0100)
If server check interval is null, we might end up looping in
process_srv_chk().

Prevent those values from being zero and add some control in
process_srv_chk() against infinite loops.

src/cfgparse.c
src/checks.c

index e5d684002d8e21e0f14fe29ed5760cd1622f4e47..6fdbe177f33b583b59907cafe8c8fd1d6836de14 100644 (file)
@@ -1931,6 +1931,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                                              file, linenum, *err, newsrv->id);
                                        return -1;
                                }
+                               if (val <= 0) {
+                                       Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
+                                             file, linenum, val, args[cur_arg], newsrv->id);
+                                       return -1;
+                               }
                                newsrv->inter = val;
                                cur_arg += 2;
                        }
@@ -1941,6 +1946,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                                              file, linenum, *err, newsrv->id);
                                        return -1;
                                }
+                               if (val <= 0) {
+                                       Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
+                                             file, linenum, val, args[cur_arg], newsrv->id);
+                                       return -1;
+                               }
                                newsrv->fastinter = val;
                                cur_arg += 2;
                        }
@@ -1951,6 +1961,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                                              file, linenum, *err, newsrv->id);
                                        return -1;
                                }
+                               if (val <= 0) {
+                                       Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
+                                             file, linenum, val, args[cur_arg], newsrv->id);
+                                       return -1;
+                               }
                                newsrv->downinter = val;
                                cur_arg += 2;
                        }
@@ -1997,6 +2012,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
                                              file, linenum, *err, newsrv->id);
                                        return -1;
                                }
+                               if (val <= 0) {
+                                       Alert("parsing [%s:%d]: invalid value %d for argument '%s' of server %s.\n",
+                                             file, linenum, val, args[cur_arg], newsrv->id);
+                                       return -1;
+                               }
                                newsrv->slowstart = (val + 999) / 1000;
                                cur_arg += 2;
                        }
index 50b464f6cd1de5488f7b7f8f31cf0d21c8ab04a3..b48179afb95f262a776e93c2c21b54dc1cc183f5 100644 (file)
@@ -524,6 +524,7 @@ static int event_srv_chk_r(int fd)
  */
 struct task *process_chk(struct task *t)
 {
+       int attempts = 0;
        struct server *s = t->context;
        struct sockaddr_in sa;
        int fd;
@@ -532,6 +533,12 @@ struct task *process_chk(struct task *t)
        //fprintf(stderr, "process_chk: task=%p\n", t);
 
  new_chk:
+       if (attempts++ > 0) {
+               /* we always fail to create a server, let's stop insisting... */
+               while (tick_is_expired(t->expire, now_ms))
+                       t->expire = tick_add(t->expire, MS_TO_TICKS(s->inter));
+               return t;
+       }
        fd = s->curfd;
        if (fd < 0) {   /* no check currently running */
                //fprintf(stderr, "process_chk: 2\n");