]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: fd: uninline compute_poll_timeout()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 17:55:29 +0000 (19:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:41:14 +0000 (01:41 +0200)
It's not needed to inline it at all (one call per loop) and it introduces
dependencies, let's move it to fd.c.

Removing the few remaining includes that came with it further reduced
by ~0.2% the LoC and the build time is now below 6s.

include/haproxy/fd.h
src/fd.c

index 245ec8d077d1ef03868f2047f0d8809bf2ff44d5..40ef38f734ab8db285bd7733c8bff181f5e49452 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 #include <import/ist.h>
-#include <haproxy/activity.h>
 #include <haproxy/api.h>
 #include <haproxy/atomic.h>
 #include <haproxy/fd-t.h>
 #include <haproxy/global.h>
 #include <haproxy/thread.h>
-#include <haproxy/ticks.h>
 
 /* public variables */
 
@@ -72,6 +70,8 @@ ssize_t fd_write_frag_line(int fd, size_t maxlen, const struct ist pfx[], size_t
 /* close all FDs starting from <start> */
 void my_closefrom(int start);
 
+int compute_poll_timeout(int next);
+
 /* disable the specified poller */
 void disable_poller(const char *poller_name);
 
@@ -340,30 +340,6 @@ static inline void fd_insert(int fd, void *owner, void (*iocb)(int fd), unsigned
        _HA_ATOMIC_INC(&ha_used_fds);
 }
 
-/* Computes the bounded poll() timeout based on the next expiration timer <next>
- * by bounding it to MAX_DELAY_MS. <next> may equal TICK_ETERNITY. The pollers
- * just needs to call this function right before polling to get their timeout
- * value. Timeouts that are already expired (possibly due to a pending event)
- * are accounted for in activity.poll_exp.
- */
-static inline int compute_poll_timeout(int next)
-{
-       int wait_time;
-
-       if (!tick_isset(next))
-               wait_time = MAX_DELAY_MS;
-       else if (tick_is_expired(next, now_ms)) {
-               activity[tid].poll_exp++;
-               wait_time = 0;
-       }
-       else {
-               wait_time = TICKS_TO_MS(tick_remain(now_ms, next)) + 1;
-               if (wait_time > MAX_DELAY_MS)
-                       wait_time = MAX_DELAY_MS;
-       }
-       return wait_time;
-}
-
 /* These are replacements for FD_SET, FD_CLR, FD_ISSET, working on uints */
 static inline void hap_fd_set(int fd, unsigned int *evts)
 {
index f6665ed57c659dcebc7af908074cf401114615f4..b796b1ae4b39c772e2f24358469e6b438de96635 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -94,6 +94,7 @@
 #include <haproxy/global.h>
 #include <haproxy/log.h>
 #include <haproxy/port_range.h>
+#include <haproxy/ticks.h>
 #include <haproxy/tools.h>
 
 
@@ -699,6 +700,30 @@ void my_closefrom(int start)
 }
 #endif // defined(USE_POLL)
 
+/* Computes the bounded poll() timeout based on the next expiration timer <next>
+ * by bounding it to MAX_DELAY_MS. <next> may equal TICK_ETERNITY. The pollers
+ * just needs to call this function right before polling to get their timeout
+ * value. Timeouts that are already expired (possibly due to a pending event)
+ * are accounted for in activity.poll_exp.
+ */
+int compute_poll_timeout(int next)
+{
+       int wait_time;
+
+       if (!tick_isset(next))
+               wait_time = MAX_DELAY_MS;
+       else if (tick_is_expired(next, now_ms)) {
+               activity[tid].poll_exp++;
+               wait_time = 0;
+       }
+       else {
+               wait_time = TICKS_TO_MS(tick_remain(now_ms, next)) + 1;
+               if (wait_time > MAX_DELAY_MS)
+                       wait_time = MAX_DELAY_MS;
+       }
+       return wait_time;
+}
+
 /* disable the specified poller */
 void disable_poller(const char *poller_name)
 {