OPTIM: connection: pack the struct target

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.
This commit is contained in:
Willy Tarreau 2012-10-13 14:33:58 +02:00
parent 109e95a1b4
commit 378e041797

View File

@ -208,7 +208,7 @@ struct target {
struct task *t; /* when type is TARG_TYPE_TASK */ struct task *t; /* when type is TARG_TYPE_TASK */
struct listener *l; /* when type is TARG_TYPE_CLIENT */ struct listener *l; /* when type is TARG_TYPE_CLIENT */
} ptr; } ptr;
}; } __attribute__((packed));
/* This structure describes a connection with its methods and data. /* This structure describes a connection with its methods and data.
* A connection may be performed to proxy or server via a local or remote * 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. * connections, but other methods for applets.
*/ */
struct connection { struct connection {
const struct xprt_ops *xprt; /* operations at the transport layer */
const struct protocol *ctrl; /* operations at the socket 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 */ 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) */ void *owner; /* pointer to upper layer's entity (eg: stream interface) */
union { /* definitions which depend on connection type */ union { /* definitions which depend on connection type */
struct { /*** information used by socket-based connections ***/ struct { /*** information used by socket-based connections ***/
int fd; /* file descriptor for a stream driver when known */ int fd; /* file descriptor for a stream driver when known */
} sock; } sock;
} t; } 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 target target; /* the target to connect to (server, proxy, applet, ...) */
struct { struct {
struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */ struct sockaddr_storage from; /* client address, or address to spoof when connecting to the server */