]> git.kaiwu.me - 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 18:04:24 +0000 (19:04 +0100)
[cherry-picked from commit e38388033f3df181ff6a2ee227789cd743d17dc1]

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 d01b4754ab218a131ea51a9887116d1e7d2720bc..2d226baf03211243e482297ab848a1b68d440c33 100644 (file)
@@ -1638,6 +1638,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;
                        }
@@ -1648,6 +1653,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;
                        }
@@ -1658,6 +1668,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;
                        }
@@ -1704,6 +1719,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 82de2603738638f6905485dd931fa40ea7740497..a0bca95ca2820206ec7c3e794d815f119313fe6d 100644 (file)
@@ -529,6 +529,7 @@ static int event_srv_chk_r(int fd)
 void process_chk(struct task *t, struct timeval *next)
 {
        __label__ new_chk, out;
+       int attempts = 0;
        struct server *s = t->context;
        struct sockaddr_in sa;
        int fd;
@@ -537,6 +538,14 @@ void process_chk(struct task *t, struct timeval *next)
        //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 (tv_isle(&t->expire, &now))
+                       tv_ms_add(&t->expire, &t->expire, s->inter);
+               task_queue(t);  /* restore t to its place in the task list */
+               *next = t->expire;
+               goto out;
+       }
        fd = s->curfd;
        if (fd < 0) {   /* no check currently running */
                //fprintf(stderr, "process_chk: 2\n");