diff --git a/include/haproxy/server-t.h b/include/haproxy/server-t.h index ed3c36e95..f0afac7dc 100644 --- a/include/haproxy/server-t.h +++ b/include/haproxy/server-t.h @@ -377,7 +377,7 @@ struct server { /* The elements below may be changed on every single request by any * thread, and generally at the same time. */ - THREAD_PAD(63); + THREAD_ALIGN(64); struct eb32_node idle_node; /* When to next do cleanup in the idle connections */ unsigned int curr_idle_conns; /* Current number of orphan idling connections, both the idle and the safe lists */ unsigned int curr_idle_nb; /* Current number of connections in the idle list */ @@ -392,7 +392,7 @@ struct server { /* Element below are usd by LB algorithms and must be doable in * parallel to other threads reusing connections above. */ - THREAD_PAD(63); + THREAD_ALIGN(64); __decl_thread(HA_SPINLOCK_T lock); /* may enclose the proxy's lock, must not be taken under */ union { struct eb32_node lb_node; /* node used for tree-based load balancing */ @@ -406,14 +406,14 @@ struct server { }; /* usually atomically updated by any thread during parsing or on end of request */ - THREAD_PAD(63); + THREAD_ALIGN(64); int cur_sess; /* number of currently active sessions (including syn_sent) */ int served; /* # of active sessions currently being served (ie not pending) */ int consecutive_errors; /* current number of consecutive errors */ struct be_counters counters; /* statistics counters */ /* Below are some relatively stable settings, only changed under the lock */ - THREAD_PAD(63); + THREAD_ALIGN(64); struct eb_root *lb_tree; /* we want to know in what tree the server is */ struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */ diff --git a/include/haproxy/server.h b/include/haproxy/server.h index dc0e263c8..9d401ffc9 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -184,16 +184,14 @@ const struct mux_ops *srv_get_ws_proto(struct server *srv); */ static inline struct server *srv_alloc(void) { - struct server *srv; - - srv = calloc(1, sizeof(*srv)); - return srv; + return ha_aligned_zalloc_typed(1, struct server); } /* free a previously allocated server an nullifies the pointer */ static inline void srv_free(struct server **srv_ptr) { - ha_free(srv_ptr); + ha_aligned_free(*srv_ptr); + *srv_ptr = NULL; } /* increase the number of cumulated streams on the designated server */