mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 09:07:02 +02:00
REORG: polling: rename "fd_spec" to "fd_cache"
So fd_spec was renamed "fd_cache" as it's becoming an event cache, and fd_nbspec becomes fd_cache_num.
This commit is contained in:
parent
15a4dec87e
commit
16f649c82c
@ -31,10 +31,10 @@
|
|||||||
#include <types/fd.h>
|
#include <types/fd.h>
|
||||||
|
|
||||||
/* public variables */
|
/* public variables */
|
||||||
extern int fd_nbspec; // number of speculative events in the list
|
extern unsigned int *fd_cache; // FD events cache
|
||||||
extern int fd_nbupdt; // number of updates in the list
|
extern unsigned int *fd_updt; // FD updates list
|
||||||
extern unsigned int *fd_spec; // speculative I/O list
|
extern int fd_cache_num; // number of events in the cache
|
||||||
extern unsigned int *fd_updt; // FD updates list
|
extern int fd_nbupdt; // number of updates in the list
|
||||||
|
|
||||||
/* Deletes an FD from the fdsets, and recomputes the maxfd limit.
|
/* Deletes an FD from the fdsets, and recomputes the maxfd limit.
|
||||||
* The file descriptor is also closed.
|
* The file descriptor is also closed.
|
||||||
@ -100,9 +100,9 @@ static inline void alloc_spec_entry(const int fd)
|
|||||||
if (fdtab[fd].cache)
|
if (fdtab[fd].cache)
|
||||||
/* FD already in speculative I/O list */
|
/* FD already in speculative I/O list */
|
||||||
return;
|
return;
|
||||||
fd_nbspec++;
|
fd_cache_num++;
|
||||||
fdtab[fd].cache = fd_nbspec;
|
fdtab[fd].cache = fd_cache_num;
|
||||||
fd_spec[fd_nbspec-1] = fd;
|
fd_cache[fd_cache_num-1] = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Removes entry used by fd <fd> from the spec list and replaces it with the
|
/* Removes entry used by fd <fd> from the spec list and replaces it with the
|
||||||
@ -117,11 +117,11 @@ static inline void release_spec_entry(int fd)
|
|||||||
if (!pos)
|
if (!pos)
|
||||||
return;
|
return;
|
||||||
fdtab[fd].cache = 0;
|
fdtab[fd].cache = 0;
|
||||||
fd_nbspec--;
|
fd_cache_num--;
|
||||||
if (likely(pos <= fd_nbspec)) {
|
if (likely(pos <= fd_cache_num)) {
|
||||||
/* was not the last entry */
|
/* was not the last entry */
|
||||||
fd = fd_spec[fd_nbspec];
|
fd = fd_cache[fd_cache_num];
|
||||||
fd_spec[pos - 1] = fd;
|
fd_cache[pos - 1] = fd;
|
||||||
fdtab[fd].cache = pos;
|
fdtab[fd].cache = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4525,7 +4525,7 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct se
|
|||||||
obj_base_ptr(conn->target));
|
obj_base_ptr(conn->target));
|
||||||
|
|
||||||
chunk_appendf(&trash,
|
chunk_appendf(&trash,
|
||||||
" flags=0x%08x fd=%d fd_spec_e=%02x fd_spec_p=%d updt=%d\n",
|
" flags=0x%08x fd=%d fd.state=%02x fd.cache=%d updt=%d\n",
|
||||||
conn->flags,
|
conn->flags,
|
||||||
conn->t.sock.fd,
|
conn->t.sock.fd,
|
||||||
conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].state : 0,
|
conn->t.sock.fd >= 0 ? fdtab[conn->t.sock.fd].state : 0,
|
||||||
|
@ -111,7 +111,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
|
|
||||||
/* compute the epoll_wait() timeout */
|
/* compute the epoll_wait() timeout */
|
||||||
|
|
||||||
if (fd_nbspec || run_queue || signal_queue_len) {
|
if (fd_cache_num || run_queue || signal_queue_len) {
|
||||||
/* Maybe we still have events in the spec list, or there are
|
/* Maybe we still have events in the spec list, or there are
|
||||||
* some tasks left pending in the run_queue, so we must not
|
* some tasks left pending in the run_queue, so we must not
|
||||||
* wait in epoll() otherwise we would delay their delivery by
|
* wait in epoll() otherwise we would delay their delivery by
|
||||||
|
@ -104,7 +104,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_nsec = 0;
|
timeout.tv_nsec = 0;
|
||||||
|
|
||||||
if (!fd_nbspec && !run_queue && !signal_queue_len) {
|
if (!fd_cache_num && !run_queue && !signal_queue_len) {
|
||||||
if (!exp) {
|
if (!exp) {
|
||||||
delta_ms = MAX_DELAY_MS;
|
delta_ms = MAX_DELAY_MS;
|
||||||
timeout.tv_sec = (MAX_DELAY_MS / 1000);
|
timeout.tv_sec = (MAX_DELAY_MS / 1000);
|
||||||
|
@ -126,7 +126,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now let's wait for events */
|
/* now let's wait for events */
|
||||||
if (fd_nbspec || run_queue || signal_queue_len)
|
if (fd_cache_num || run_queue || signal_queue_len)
|
||||||
wait_time = 0;
|
wait_time = 0;
|
||||||
else if (!exp)
|
else if (!exp)
|
||||||
wait_time = MAX_DELAY_MS;
|
wait_time = MAX_DELAY_MS;
|
||||||
|
@ -93,7 +93,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
delta.tv_sec = 0;
|
delta.tv_sec = 0;
|
||||||
delta.tv_usec = 0;
|
delta.tv_usec = 0;
|
||||||
|
|
||||||
if (!fd_nbspec && !run_queue && !signal_queue_len) {
|
if (!fd_cache_num && !run_queue && !signal_queue_len) {
|
||||||
if (!exp) {
|
if (!exp) {
|
||||||
delta_ms = MAX_DELAY_MS;
|
delta_ms = MAX_DELAY_MS;
|
||||||
delta.tv_sec = (MAX_DELAY_MS / 1000);
|
delta.tv_sec = (MAX_DELAY_MS / 1000);
|
||||||
|
25
src/fd.c
25
src/fd.c
@ -105,11 +105,10 @@ struct poller pollers[MAX_POLLERS];
|
|||||||
struct poller cur_poller;
|
struct poller cur_poller;
|
||||||
int nbpollers = 0;
|
int nbpollers = 0;
|
||||||
|
|
||||||
/* FD status is defined by the poller's status and by the speculative I/O list */
|
unsigned int *fd_cache = NULL; // FD events cache
|
||||||
int fd_nbspec = 0; // number of speculative events in the list
|
|
||||||
int fd_nbupdt = 0; // number of updates in the list
|
|
||||||
unsigned int *fd_spec = NULL; // speculative I/O list
|
|
||||||
unsigned int *fd_updt = NULL; // FD updates list
|
unsigned int *fd_updt = NULL; // FD updates list
|
||||||
|
int fd_cache_num = 0; // number of events in the cache
|
||||||
|
int fd_nbupdt = 0; // number of updates in the list
|
||||||
|
|
||||||
/* Deletes an FD from the fdsets, and recomputes the maxfd limit.
|
/* Deletes an FD from the fdsets, and recomputes the maxfd limit.
|
||||||
* The file descriptor is also closed.
|
* The file descriptor is also closed.
|
||||||
@ -146,8 +145,8 @@ void fd_process_spec_events()
|
|||||||
|
|
||||||
/* now process speculative events if any */
|
/* now process speculative events if any */
|
||||||
|
|
||||||
for (spec_idx = 0; spec_idx < fd_nbspec; ) {
|
for (spec_idx = 0; spec_idx < fd_cache_num; ) {
|
||||||
fd = fd_spec[spec_idx];
|
fd = fd_cache[spec_idx];
|
||||||
e = fdtab[fd].state;
|
e = fdtab[fd].state;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -176,7 +175,7 @@ void fd_process_spec_events()
|
|||||||
/* if the fd was removed from the spec list, it has been
|
/* if the fd was removed from the spec list, it has been
|
||||||
* replaced by the next one that we don't want to skip !
|
* replaced by the next one that we don't want to skip !
|
||||||
*/
|
*/
|
||||||
if (spec_idx < fd_nbspec && fd_spec[spec_idx] != fd)
|
if (spec_idx < fd_cache_num && fd_cache[spec_idx] != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
spec_idx++;
|
spec_idx++;
|
||||||
@ -202,8 +201,8 @@ int init_pollers()
|
|||||||
int p;
|
int p;
|
||||||
struct poller *bp;
|
struct poller *bp;
|
||||||
|
|
||||||
if ((fd_spec = (uint32_t *)calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
if ((fd_cache = (uint32_t *)calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
||||||
goto fail_spec;
|
goto fail_cache;
|
||||||
|
|
||||||
if ((fd_updt = (uint32_t *)calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
if ((fd_updt = (uint32_t *)calloc(1, sizeof(uint32_t) * global.maxsock)) == NULL)
|
||||||
goto fail_updt;
|
goto fail_updt;
|
||||||
@ -225,8 +224,8 @@ int init_pollers()
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail_updt:
|
fail_updt:
|
||||||
free(fd_spec);
|
free(fd_cache);
|
||||||
fail_spec:
|
fail_cache:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,9 +245,9 @@ void deinit_pollers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(fd_updt);
|
free(fd_updt);
|
||||||
free(fd_spec);
|
free(fd_cache);
|
||||||
fd_updt = NULL;
|
fd_updt = NULL;
|
||||||
fd_spec = NULL;
|
fd_cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user