]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] proxy: merge maintain_proxies() operation inside a single loop
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2011 09:54:17 +0000 (11:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Jul 2011 09:54:17 +0000 (11:54 +0200)
This will help transforming the processing into per-proxy tasks.

src/proxy.c

index 17063a65f94b8b630cc444103140b01a746dca7f..9b882749db80ce29da7b6a3f7bae1c313f98bcc4 100644 (file)
@@ -486,6 +486,25 @@ void maintain_proxies(int *next)
                 */
 
                for (; p; p = p->next) {
+                       /* first, let's check if we need to stop the proxy */
+                       if (unlikely(stopping && p->state != PR_STSTOPPED)) {
+                               int t;
+                               t = tick_remain(now_ms, p->stop_time);
+                               if (t == 0) {
+                                       Warning("Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
+                                               p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                                       send_log(p, LOG_WARNING, "Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
+                                                p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
+                                       stop_proxy(p);
+                                       /* try to free more memory */
+                                       pool_gc2();
+                               }
+                               else {
+                                       *next = tick_first(*next, p->stop_time);
+                               }
+                       }
+
+                       /* the rest below is just for frontends */
                        if (!(p->cap & PR_CAP_FE))
                                continue;
 
@@ -516,30 +535,6 @@ void maintain_proxies(int *next)
                                dequeue_all_listeners(&p->listener_queue);
                }
        }
-
-       if (stopping) {
-               p = proxy;
-               while (p) {
-                       if (p->state != PR_STSTOPPED) {
-                               int t;
-                               t = tick_remain(now_ms, p->stop_time);
-                               if (t == 0) {
-                                       Warning("Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
-                                               p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
-                                       send_log(p, LOG_WARNING, "Proxy %s stopped (FE: %lld conns, BE: %lld conns).\n",
-                                                p->id, p->fe_counters.cum_conn, p->be_counters.cum_conn);
-                                       stop_proxy(p);
-                                       /* try to free more memory */
-                                       pool_gc2();
-                               }
-                               else {
-                                       *next = tick_first(*next, p->stop_time);
-                               }
-                       }
-                       p = p->next;
-               }
-       }
-       return;
 }