]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: connection: pack the struct target
authorWilly Tarreau <w@1wt.eu>
Sat, 13 Oct 2012 12:33:58 +0000 (14:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 13 Oct 2012 12:33:58 +0000 (14:33 +0200)
The struct target contains one int and one pointer, causing it to be
64-bit aligned on 64-bit platforms. By marking it "packed", we can
save 8 bytes in struct connection and as many in struct session on
such platforms.

include/types/connection.h

index 5803c2c2ec41102c83f6651e3cdc494840bb4600..299093bee06b7e01ab03ce685d6487102e10b2c3 100644 (file)
@@ -208,7 +208,7 @@ struct target {
                struct task *t;       /* when type is TARG_TYPE_TASK */
                struct listener *l;   /* when type is TARG_TYPE_CLIENT */
        } ptr;
-};
+} __attribute__((packed));
 
 /* This structure describes a connection with its methods and data.
  * A connection may be performed to proxy or server via a local or remote
@@ -218,18 +218,18 @@ struct target {
  * connections, but other methods for applets.
  */
 struct connection {
-       const struct xprt_ops *xprt;  /* operations at the transport layer */
        const struct protocol *ctrl;  /* operations at the socket layer */
+       const struct xprt_ops *xprt;  /* operations at the transport layer */
        const struct data_cb  *data;  /* data layer callbacks */
+       unsigned int flags;           /* CO_F_* */
+       int xprt_st;                  /* transport layer state, initialized to zero */
+       void *xprt_ctx;               /* general purpose pointer, initialized to NULL */
        void *owner;                  /* pointer to upper layer's entity (eg: stream interface) */
        union {                       /* definitions which depend on connection type */
                struct {              /*** information used by socket-based connections ***/
                        int fd;       /* file descriptor for a stream driver when known */
                } sock;
        } t;
-       unsigned int flags;           /* CO_F_* */
-       int xprt_st;                  /* transport layer state, initialized to zero */
-       void *xprt_ctx;               /* general purpose pointer, initialized to NULL */
        struct target target;         /* the target to connect to (server, proxy, applet, ...) */
        struct {
                struct sockaddr_storage from;   /* client address, or address to spoof when connecting to the server */