]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
* a never ending connect() could lead to a fast select() loop if
authorWilly TARREAU <willy@pcw.(none)>
Wed, 1 Mar 2006 21:33:49 +0000 (22:33 +0100)
committerWilly TARREAU <willy@pcw.(none)>
Wed, 1 Mar 2006 21:33:49 +0000 (22:33 +0100)
  its timeout times the number of retransmits exceeded the server
  read or write timeout, because the later was used to compute
  select()'s timeout while the connection timeout was not reached.

haproxy.c

index 0da06a9f459916bb9f17e0dd5b44e8dba24afd5b..5cf60af98106da9e0e26d628862d83087ea31cb9 100644 (file)
--- a/haproxy.c
+++ b/haproxy.c
@@ -2345,13 +2345,18 @@ int event_srv_write(int fd) {
        fdtab[fd].state = FD_STERROR;
     }
 
-    if (s->proxy->srvtimeout) {
-       tv_delayfrom(&s->swexpire, &now, s->proxy->srvtimeout);
-       /* FIXME: to avoid the server to read-time-out during writes, we refresh it */
-       s->srexpire = s->swexpire;
+    /* We don't want to re-arm read/write timeouts if we're trying to connect,
+     * otherwise it could loop indefinitely !
+     */
+    if (s->srv_state != SV_STCONN) {
+       if (s->proxy->srvtimeout) {
+           tv_delayfrom(&s->swexpire, &now, s->proxy->srvtimeout);
+           /* FIXME: to avoid the server to read-time-out during writes, we refresh it */
+           s->srexpire = s->swexpire;
+       }
+       else
+           tv_eternity(&s->swexpire);
     }
-    else
-       tv_eternity(&s->swexpire);
 
     task_wakeup(&rq, t);
     return 0;
@@ -4946,6 +4951,14 @@ int process_session(struct task *t) {
        /* restore t to its place in the task list */
        task_queue(t);
 
+#ifdef DEBUG_FULL
+       /* DEBUG code : this should never ever happen, otherwise it indicates
+        * that a task still has something to do and will provoke a quick loop.
+        */
+       if (tv_remain2(&now, &t->expire) <= 0)
+           exit(100);
+#endif
+
        return tv_remain2(&now, &t->expire); /* nothing more to do */
     }