mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-09 23:39:55 +00:00
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.
This commit is contained in:
parent
c91f608bcb
commit
b63888c67c
@ -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 @@ 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)
|
||||
{
|
||||
|
25
src/fd.c
25
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user