]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: move .cloned into fdtab[].state
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Apr 2021 15:53:33 +0000 (17:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Apr 2021 16:08:29 +0000 (18:08 +0200)
No need to keep this flag apart any more, let's merge it into the global
state.

include/haproxy/fd-t.h
include/haproxy/fd.h
src/cli.c
src/ev_epoll.c
src/fd.c

index d15a97715d9841b7c13cbbecd293c0ed5232fa0f..1f558400637e8e925781e2f47acd578a614c2c48 100644 (file)
@@ -64,6 +64,7 @@ enum {
 
 /* info/config bits */
 #define FD_LINGER_RISK_BIT 16  /* must kill lingering before closing */
+#define FD_CLONED_BIT      17  /* cloned socket, requires EPOLL_CTL_DEL on close */
 
 
 /* and flag values */
@@ -99,6 +100,7 @@ enum {
 
 /* information/configuration flags */
 #define FD_LINGER_RISK      (1U << FD_LINGER_RISK_BIT)
+#define FD_CLONED           (1U << FD_CLONED_BIT)
 
 /* This is the value used to mark a file descriptor as dead. This value is
  * negative, this is important so that tests on fd < 0 properly match. It
@@ -147,7 +149,6 @@ struct fdtab {
        void (*iocb)(int fd);                /* I/O handler */
        void *owner;                         /* the connection or listener associated with this fd, NULL if closed */
        unsigned int state;                  /* FD state for read and write directions (FD_EV_*) + FD_POLL_* */
-       unsigned char cloned:1;              /* 1 if a cloned socket, requires EPOLL_CTL_DEL on close */
        unsigned char initialized:1;         /* 1 if init phase was done on this fd (e.g. set non-blocking) */
        unsigned char et_possible:1;         /* 1 if edge-triggered is possible on this FD */
        unsigned char exported:1;            /* 1 if the FD is exported and must not be closed */
index df9df1607aebcf417d1cb9df21d058bb2a345cdb..11dce3d9df4bad4249bd38276c548214c97cb84a 100644 (file)
@@ -433,7 +433,6 @@ static inline void fd_insert(int fd, void *owner, void (*iocb)(int fd), unsigned
        fdtab[fd].owner = owner;
        fdtab[fd].iocb = iocb;
        fdtab[fd].state = 0;
-       fdtab[fd].cloned = 0;
        fdtab[fd].et_possible = 0;
        fdtab[fd].exported = 0;
 #ifdef DEBUG_FD
index 7c1b0291ef4d447043c80251ec66c889cc1176ca..08c35da0f38b1c2a7e70ffb39b5e40e8f2553bad 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1203,7 +1203,7 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
                             (fdt.state & FD_POLL_PRI) ? 'P' : 'p',
                             (fdt.state & FD_POLL_IN)  ? 'I' : 'i',
                             (fdt.state & FD_LINGER_RISK) ? 'L' : 'l',
-                            fdt.cloned ? 'C' : 'c',
+                            (fdt.state & FD_CLONED) ? 'C' : 'c',
                             fdt.thread_mask, fdt.update_mask,
                             fdt.owner,
                             fdt.iocb);
index f43875cffc3e1973f52ecb8fbb1e2c386bd29d70..22ad454c8d7982f5a26b016cddb5719ca20e9dce 100644 (file)
@@ -41,7 +41,7 @@ static int epoll_fd[MAX_THREADS]; // per-thread epoll_fd
  */
 static void __fd_clo(int fd)
 {
-       if (unlikely(fdtab[fd].cloned)) {
+       if (unlikely(fdtab[fd].state & FD_CLONED)) {
                unsigned long m = polled_mask[fd].poll_recv | polled_mask[fd].poll_send;
                struct epoll_event ev;
                int i;
index e29814b628dc2fb541a602255ddd0435e774e43b..64e4e9cc0e1d7fd007dc8e968656ba8d9f054780 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -819,7 +819,7 @@ int fork_poller()
        int fd;
        for (fd = 0; fd < global.maxsock; fd++) {
                if (fdtab[fd].owner) {
-                       fdtab[fd].cloned = 1;
+                       HA_ATOMIC_OR(&fdtab[fd].state, FD_CLONED);
                }
        }