]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: fd: move .exported into fdtab[].state
authorWilly Tarreau <w@1wt.eu>
Tue, 6 Apr 2021 16:09:06 +0000 (18:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Apr 2021 16:10:36 +0000 (18:10 +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/fd.c
src/sock_inet.c
src/sock_unix.c

index e60f3b52fb791d02795e7ec8a502dbc865c7e18f..9108b4ea42639f6e4a55aea27c55cfa0993080b6 100644 (file)
@@ -67,6 +67,7 @@ enum {
 #define FD_CLONED_BIT      17  /* cloned socket, requires EPOLL_CTL_DEL on close */
 #define FD_INITIALIZED_BIT 18  /* init phase was done (e.g. output pipe set non-blocking) */
 #define FD_ET_POSSIBLE_BIT 19  /* edge-triggered is possible on this FD */
+#define FD_EXPORTED_BIT    20  /* FD is exported and must not be closed */
 
 
 /* and flag values */
@@ -105,6 +106,7 @@ enum {
 #define FD_CLONED           (1U << FD_CLONED_BIT)
 #define FD_INITIALIZED      (1U << FD_INITIALIZED_BIT)
 #define FD_ET_POSSIBLE      (1U << FD_ET_POSSIBLE_BIT)
+#define FD_EXPORTED         (1U << FD_EXPORTED_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
@@ -153,7 +155,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 exported:1;            /* 1 if the FD is exported and must not be closed */
 #ifdef DEBUG_FD
        unsigned int event_count;            /* number of events reported */
 #endif
index ba9bf8c222cc8df2ee6da27b245a3e091cecce30..37c9ac536200488804cd71446ef2b7d84813ee24 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].exported = 0;
 #ifdef DEBUG_FD
        fdtab[fd].event_count = 0;
 #endif
index 08c35da0f38b1c2a7e70ffb39b5e40e8f2553bad..575a1730ea16756e6edf7ae278a984da355a6594 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1889,7 +1889,7 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr
         * the caller know how much it should expect.
         */
        for (cur_fd = 0;cur_fd < global.maxsock; cur_fd++)
-               tot_fd_nb += fdtab[cur_fd].exported;
+               tot_fd_nb += !!(fdtab[cur_fd].state & FD_EXPORTED);
 
        if (tot_fd_nb == 0)
                goto out;
@@ -1933,7 +1933,7 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr
        nb_queued = 0;
        iov.iov_base = tmpbuf;
        for (cur_fd = 0; cur_fd < global.maxsock; cur_fd++) {
-               if (!(fdtab[cur_fd].exported))
+               if (!(fdtab[cur_fd].state & FD_EXPORTED))
                        continue;
 
                ns_name = if_name = "";
index fe9db237c4dd80d972027a7c0b1365987bbada39..d63abbf54b0d789bb2b4507e31f231a46f0fd406 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -320,7 +320,6 @@ void _fd_delete_orphan(int fd)
 #endif
        fdinfo[fd].port_range = NULL;
        fdtab[fd].owner = NULL;
-       fdtab[fd].exported = 0;
        /* perform the close() call last as it's what unlocks the instant reuse
         * of this FD by any other thread.
         */
index ab881d86969a02ffe64039e9e21cf89167dc5d2d..fb6998143f1025d7d74987a2701b3161fbbe223d 100644 (file)
@@ -395,7 +395,7 @@ int sock_inet_bind_receiver(struct receiver *rx, char **errmsg)
 
        /* for now, all regularly bound TCP listeners are exportable */
        if (!(rx->flags & RX_F_INHERITED))
-               fdtab[fd].exported = 1;
+               HA_ATOMIC_OR(&fdtab[fd].state, FD_EXPORTED);
 
  bind_return:
        if (errmsg && *errmsg) {
index 45631ac17a0631af6d5cc92457c99efa4462f8ca..9913f4f83870f5f8d6e8e3cc91a2961a20b37a2a 100644 (file)
@@ -289,7 +289,7 @@ int sock_unix_bind_receiver(struct receiver *rx, char **errmsg)
 
        /* for now, all regularly bound TCP listeners are exportable */
        if (!(rx->flags & RX_F_INHERITED))
-               fdtab[fd].exported = 1;
+               HA_ATOMIC_OR(&fdtab[fd].state, FD_EXPORTED);
 
        return err;