REORG: include: move fd.h to haproxy/fd{,-t}.h
A few includes were missing in each file. A definition of
struct polled_mask was moved to fd-t.h. The MAX_POLLERS macro was
moved to defaults.h
Stdio used to be silently inherited from whatever path but it's needed
for list_pollers() which takes a FILE* and which can thus not be
forward-declared.
diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h
index 165c78b..dff5436 100644
--- a/include/haproxy/defaults.h
+++ b/include/haproxy/defaults.h
@@ -347,4 +347,9 @@
#define DEFAULT_PAT_LRU_SIZE 10000
#endif
+/* maximum number of pollers that may be registered */
+#ifndef MAX_POLLERS
+#define MAX_POLLERS 10
+#endif
+
#endif /* _HAPROXY_DEFAULTS_H */
diff --git a/include/types/fd.h b/include/haproxy/fd-t.h
similarity index 90%
rename from include/types/fd.h
rename to include/haproxy/fd-t.h
index 66fab44..5f1c173 100644
--- a/include/types/fd.h
+++ b/include/haproxy/fd-t.h
@@ -1,5 +1,5 @@
/*
- * include/types/fd.h
+ * include/haproxy/fd-t.h
* File descriptors states - check src/fd.c for explanations.
*
* Copyright (C) 2000-2014 Willy Tarreau - w@1wt.eu
@@ -19,11 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _TYPES_FD_H
-#define _TYPES_FD_H
+#ifndef _HAPROXY_FD_T_H
+#define _HAPROXY_FD_T_H
#include <haproxy/api-t.h>
-#include <import/ist.h>
#include <haproxy/port_range-t.h>
/* Direction for each FD event update */
@@ -107,13 +106,13 @@
struct fdlist_entry {
int next;
int prev;
-} __attribute__ ((aligned(8)));
+} ALIGNED(8);
/* head of the fd cache */
struct fdlist {
int first;
int last;
-} __attribute__ ((aligned(8)));
+} ALIGNED(8);
/* info about one given fd */
struct fdtab {
@@ -133,10 +132,16 @@
/* only align on cache lines when using threads; 32-bit small archs
* can put everything in 32-bytes when threads are disabled.
*/
-__attribute__((aligned(64)))
+ALIGNED(64)
#endif
;
+/* polled mask, one bit per thread and per direction for each FD */
+struct polled_mask {
+ unsigned long poll_recv;
+ unsigned long poll_send;
+};
+
/* less often used information */
struct fdinfo {
struct port_range *port_range; /* optional port range to bind to */
@@ -174,17 +179,7 @@
int pref; /* try pollers with higher preference first */
};
-extern struct poller cur_poller; /* the current poller */
-extern int nbpollers;
-#define MAX_POLLERS 10
-extern struct poller pollers[MAX_POLLERS]; /* all registered pollers */
-
-extern struct fdtab *fdtab; /* array of all the file descriptors */
-extern struct fdinfo *fdinfo; /* less-often used infos for file descriptors */
-extern int totalconn; /* total # of terminated sessions */
-extern int actconn; /* # of active sessions */
-
-#endif /* _TYPES_FD_H */
+#endif /* _HAPROXY_FD_T_H */
/*
* Local variables:
diff --git a/include/proto/fd.h b/include/haproxy/fd.h
similarity index 94%
rename from include/proto/fd.h
rename to include/haproxy/fd.h
index 6544239..0f1799d 100644
--- a/include/proto/fd.h
+++ b/include/haproxy/fd.h
@@ -1,8 +1,8 @@
/*
- * include/proto/fd.h
- * File descriptors states.
+ * include/haproxy/fd.h
+ * File descriptors states - exported variables and functions
*
- * Copyright (C) 2000-2014 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,29 +19,33 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _PROTO_FD_H
-#define _PROTO_FD_H
+#ifndef _HAPROXY_FD_H
+#define _HAPROXY_FD_H
-#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <stdio.h>
#include <unistd.h>
-
+#include <import/ist.h>
+#include <haproxy/activity.h>
#include <haproxy/api.h>
+#include <haproxy/fd-t.h>
+#include <haproxy/thread.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>
-#include <types/fd.h>
-#include <haproxy/activity.h>
/* public variables */
-extern volatile struct fdlist update_list;
-
+extern struct poller cur_poller; /* the current poller */
+extern int nbpollers;
+extern struct poller pollers[MAX_POLLERS]; /* all registered pollers */
+extern struct fdtab *fdtab; /* array of all the file descriptors */
+extern struct fdinfo *fdinfo; /* less-often used infos for file descriptors */
+extern int totalconn; /* total # of terminated sessions */
+extern int actconn; /* # of active sessions */
-extern struct polled_mask {
- unsigned long poll_recv;
- unsigned long poll_send;
-} *polled_mask;
+extern volatile struct fdlist update_list;
+extern struct polled_mask *polled_mask;
extern THREAD_LOCAL int *fd_updt; // FD updates list
extern THREAD_LOCAL int fd_nbupdt; // number of updates in the list
@@ -66,6 +70,7 @@
*/
int fd_takeover(int fd, void *expected_owner);
+/* lock used by FD migration */
#ifndef HA_HAVE_CAS_DW
__decl_thread(extern HA_RWLOCK_T fd_mig_lock);
#endif
@@ -497,7 +502,7 @@
}
-#endif /* _PROTO_FD_H */
+#endif /* _HAPROXY_FD_H */
/*
* Local variables:
diff --git a/include/proto/connection.h b/include/proto/connection.h
index de976d7..9cf1aaa 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -27,7 +27,7 @@
#include <haproxy/pool.h>
#include <types/connection.h>
#include <types/listener.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/obj_type.h>
#include <proto/session.h>
#include <proto/task.h>
diff --git a/include/proto/stream.h b/include/proto/stream.h
index 80c56ef..ac55545 100644
--- a/include/proto/stream.h
+++ b/include/proto/stream.h
@@ -26,7 +26,7 @@
#include <haproxy/pool.h>
#include <types/action.h>
#include <types/stream.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/obj_type.h>
#include <proto/queue.h>
diff --git a/include/proto/task.h b/include/proto/task.h
index c928a11..17a8288 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -38,7 +38,7 @@
#include <types/global.h>
#include <types/task.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
/* Principle of the wait queue.
*
diff --git a/src/checks.c b/src/checks.c
index 499bc51..3d3fbd1 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -52,7 +52,7 @@
#include <proto/backend.h>
#include <proto/checks.h>
#include <proto/stats.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/http_htx.h>
#include <proto/log.h>
#include <proto/mux_pt.h>
diff --git a/src/cli.c b/src/cli.c
index df0e0f2..bdfb270 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -48,7 +48,7 @@
#include <proto/cli.h>
#include <proto/compression.h>
#include <proto/stats.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/frontend.h>
#include <proto/log.h>
diff --git a/src/connection.c b/src/connection.c
index 688be9a..d7c77d2 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -19,7 +19,7 @@
#include <haproxy/net_helper.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/frontend.h>
#include <proto/proto_tcp.h>
#include <proto/stream_interface.h>
diff --git a/src/debug.c b/src/debug.c
index 9aef05b..bf2bc1a 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -31,7 +31,7 @@
#include <types/signal.h>
#include <proto/cli.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/hlua.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
diff --git a/src/dns.c b/src/dns.c
index 0390212..a74bd36 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -38,7 +38,7 @@
#include <proto/cli.h>
#include <proto/checks.h>
#include <proto/dns.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/http_ana.h>
#include <proto/http_rules.h>
#include <proto/log.h>
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 40f5e9c..d5717e7 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -23,7 +23,7 @@
#include <types/global.h>
#include <haproxy/activity.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/signal.h>
diff --git a/src/ev_evports.c b/src/ev_evports.c
index 9f3158a..0a18bd3 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -26,7 +26,7 @@
#include <types/global.h>
#include <haproxy/activity.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/log.h>
#include <proto/signal.h>
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index 95a6897..5746f1a 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -25,7 +25,7 @@
#include <types/global.h>
#include <haproxy/activity.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/signal.h>
diff --git a/src/ev_poll.c b/src/ev_poll.c
index 0d0fcaa..344b6d4 100644
--- a/src/ev_poll.c
+++ b/src/ev_poll.c
@@ -25,7 +25,7 @@
#include <types/global.h>
#include <haproxy/activity.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#ifndef POLLRDHUP
diff --git a/src/ev_select.c b/src/ev_select.c
index c6c3f43..6a5d2f8 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -22,7 +22,7 @@
#include <types/global.h>
#include <haproxy/activity.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
/* private data */
diff --git a/src/fd.c b/src/fd.c
index 56a0b7b..60db19c 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -91,7 +91,7 @@
#include <haproxy/api.h>
#include <types/global.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/log.h>
#include <haproxy/port_range.h>
diff --git a/src/frontend.c b/src/frontend.c
index 22e2acc..8206709 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -32,7 +32,7 @@
#include <proto/acl.h>
#include <proto/arg.h>
#include <proto/channel.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/frontend.h>
#include <proto/log.h>
#include <proto/proto_tcp.h>
diff --git a/src/haproxy.c b/src/haproxy.c
index 57fedf8..3f2dd13 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -113,7 +113,7 @@
#include <proto/channel.h>
#include <proto/cli.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/filters.h>
#include <proto/hlua.h>
#include <proto/http_rules.h>
diff --git a/src/listener.c b/src/listener.c
index ac7b328..aa935d6 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -30,7 +30,7 @@
#include <proto/acl.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/log.h>
#include <proto/listener.h>
diff --git a/src/log.c b/src/log.c
index 353b428..b036c99 100644
--- a/src/log.c
+++ b/src/log.c
@@ -36,7 +36,7 @@
#include <proto/applet.h>
#include <proto/cli.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/frontend.h>
#include <proto/log.h>
#include <proto/ring.h>
diff --git a/src/mworker.c b/src/mworker.c
index 4b2a7af..4f5ade2 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -28,7 +28,7 @@
#include <types/signal.h>
#include <proto/cli.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/mworker.h>
diff --git a/src/peers.c b/src/peers.c
index d4011d3..4d16b41 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -37,7 +37,7 @@
#include <proto/applet.h>
#include <proto/channel.h>
#include <proto/cli.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/frontend.h>
#include <proto/log.h>
#include <proto/mux_pt.h>
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index e133a84..0bff96d 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -36,7 +36,7 @@
#include <types/global.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/listener.h>
#include <proto/log.h>
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 2abfd85..9b109f4 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -44,7 +44,7 @@
#include <proto/arg.h>
#include <proto/channel.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/http_rules.h>
#include <proto/listener.h>
#include <proto/log.h>
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 810c314..a1d9176 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -11,10 +11,10 @@
*/
#include <types/global.h>
-#include <types/fd.h>
+#include <haproxy/fd-t.h>
#include <types/proto_udp.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
/* datagram handler callback */
void dgram_fd_handler(int fd)
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 429ca1c..a3eefa9 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -36,7 +36,7 @@
#include <types/global.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/listener.h>
#include <proto/log.h>
#include <haproxy/protocol.h>
diff --git a/src/proxy.c b/src/proxy.c
index a8ca53a..45750b7 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -36,7 +36,7 @@
#include <proto/applet.h>
#include <proto/cli.h>
#include <proto/backend.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/filters.h>
#include <proto/listener.h>
#include <proto/log.h>
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 6503b3b..c1af72a 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -29,7 +29,7 @@
#include <haproxy/time.h>
#include <proto/connection.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/log.h>
#include <proto/pipe.h>
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 44818d0..357828d 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -68,7 +68,7 @@
#include <proto/channel.h>
#include <proto/connection.h>
#include <proto/cli.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/frontend.h>
#include <proto/http_rules.h>
diff --git a/src/stats.c b/src/stats.c
index b43665c..115b9ad 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -51,7 +51,7 @@
#include <proto/compression.h>
#include <proto/dns.h>
#include <proto/stats.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/frontend.h>
#include <proto/http_htx.h>
diff --git a/src/stream.c b/src/stream.c
index f0e2c88..904eaef 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -41,7 +41,7 @@
#include <proto/connection.h>
#include <proto/dns.h>
#include <proto/stats.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <proto/filters.h>
#include <haproxy/freq_ctr.h>
#include <proto/frontend.h>
diff --git a/src/task.c b/src/task.c
index eacc3fd..24c3b3e 100644
--- a/src/task.c
+++ b/src/task.c
@@ -20,7 +20,7 @@
#include <import/eb32sctree.h>
#include <import/eb32tree.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
#include <haproxy/freq_ctr.h>
#include <proto/proxy.h>
#include <proto/stream.h>
diff --git a/src/thread.c b/src/thread.c
index 2a7ec9a..0ee9332 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -27,7 +27,7 @@
#include <haproxy/thread.h>
#include <haproxy/tools.h>
#include <types/global.h>
-#include <proto/fd.h>
+#include <haproxy/fd.h>
struct thread_info ha_thread_info[MAX_THREADS] = { };
THREAD_LOCAL struct thread_info *ti = &ha_thread_info[0];