REORG: fd: uninline compute_poll_timeout()
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.
diff --git a/include/haproxy/fd.h b/include/haproxy/fd.h
index 245ec8d..40ef38f 100644
--- a/include/haproxy/fd.h
+++ b/include/haproxy/fd.h
@@ -27,13 +27,11 @@
#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 @@
/* 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 @@
_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)
{
diff --git a/src/fd.c b/src/fd.c
index f6665ed..b796b1a 100644
--- 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 @@
}
#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)
{