]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DIET/MINOR: listener: rearrange a few fields in struct listener to save 16 bytes
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Dec 2013 20:18:49 +0000 (21:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 15:06:21 +0000 (16:06 +0100)
Pack the listener state to 1 char, store it as an enum instead of an
int (more gdb-friendly), and move a few fields around to fill holes.

The <nice> field can only be -1024..1024 so it was stored as a signed
short and completes well with obj_type and li_state.

Doing this has reduced the struct listener from 376 to 360 bytes (4.2%).

include/types/listener.h

index 64d3cb94778e50776f45af1cab2e909918f35c8c..47cb185eff56c357597c862797b7d9e0d753b7e6 100644 (file)
@@ -42,7 +42,7 @@ struct proxy;
 struct licounters;
 
 /* listener state */
-enum {
+enum li_state {
        LI_NEW  = 0,    /* not initialized yet */
        LI_INIT,        /* all parameters filled in, but not assigned yet */
        LI_ASSIGNED,    /* assigned to the protocol, but not listening yet */
@@ -51,7 +51,7 @@ enum {
        LI_READY,       /* started, listening and enabled */
        LI_FULL,        /* reached its connection limit */
        LI_LIMITED,     /* transient state: limits have been reached, listener is queued */
-};
+} __attribute__((packed));
 
 /* Listener transitions
  * calloc()     set()      add_listener()       bind()
@@ -153,10 +153,11 @@ struct bind_conf {
  */
 struct listener {
        enum obj_type obj_type;         /* object type = OBJ_TYPE_LISTENER */
+       enum li_state state;            /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
+       short int nice;                 /* nice value to assign to the instanciated tasks */
        int fd;                         /* the listen socket */
-       char *name;                     /* */
+       char *name;                     /* listener's name */
        int luid;                       /* listener universally unique ID, used for SNMP */
-       int state;                      /* state: NEW, INIT, ASSIGNED, LISTEN, READY, FULL */
        int options;                    /* socket options : LI_O_* */
        struct licounters *counters;    /* statistics counters */
        struct protocol *proto;         /* protocol this listener belongs to */
@@ -172,9 +173,8 @@ struct listener {
        struct proxy *frontend;         /* the frontend this listener belongs to, or NULL */
        struct list wait_queue;         /* link element to make the listener wait for something (LI_LIMITED)  */
        unsigned int analysers;         /* bitmap of required protocol analysers */
-       int nice;                       /* nice value to assign to the instanciated tasks */
-       char *interface;                /* interface name or NULL */
        int maxseg;                     /* for TCP, advertised MSS */
+       char *interface;                /* interface name or NULL */
 
        struct list by_fe;              /* chaining in frontend's list of listeners */
        struct list by_bind;            /* chaining in bind_conf's list of listeners */