DIET/MINOR: listener: rearrange a few fields in struct listener to save 16 bytes
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%).
diff --git a/include/types/listener.h b/include/types/listener.h
index 64d3cb9..47cb185 100644
--- a/include/types/listener.h
+++ b/include/types/listener.h
@@ -42,7 +42,7 @@
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 @@
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 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 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 */