]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: checks: use an inline function for health_adjust()
authorWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:47:37 +0000 (23:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Dec 2013 22:47:37 +0000 (23:47 +0100)
This function is called twice per request, and does almost always nothing.
Better use an inline version to avoid entering it when we can.

About 0.5% additional performance was gained this way.

include/proto/checks.h
src/checks.c

index f4f9c497f8366cff845298fd8ada54cc8fdea782..17ed803a481752127a313cc86508a4887be071ea 100644 (file)
@@ -30,10 +30,22 @@ const char *get_check_status_info(short check_status);
 void set_server_down(struct check *check);
 void set_server_up(struct check *check);
 int start_checks();
-void health_adjust(struct server *s, short status);
+void __health_adjust(struct server *s, short status);
 
 extern struct data_cb check_conn_cb;
 
+/* Use this one only. This inline version only ensures that we don't
+ * call the function when the observe mode is disabled.
+ */
+static inline void health_adjust(struct server *s, short status)
+{
+       /* return now if observing nor health check is not enabled */
+       if (!s->observe || !s->check.task)
+               return;
+
+       return __health_adjust(s, status);
+}
+
 #endif /* _PROTO_CHECKS_H */
 
 /*
index c055017532323b8012b656206060bfc2a554b56a..c302866977f5ed32870f8d3212b0b5b6b54ce4ef 100644 (file)
@@ -641,15 +641,14 @@ static void check_failed(struct check *check)
                set_server_down(check);
 }
 
-void health_adjust(struct server *s, short status)
+/* note: use health_adjust() only, which first checks that the observe mode is
+ * enabled.
+ */
+void __health_adjust(struct server *s, short status)
 {
        int failed;
        int expire;
 
-       /* return now if observing nor health check is not enabled */
-       if (!s->observe || !s->check.task)
-               return;
-
        if (s->observe >= HANA_OBS_SIZE)
                return;