diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index c3f9f9525..52cac0818 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/haproxy/acl-t.h b/include/haproxy/acl-t.h index d2b0e3133..8418ca95f 100644 --- a/include/haproxy/acl-t.h +++ b/include/haproxy/acl-t.h @@ -27,10 +27,9 @@ #include #include #include +#include #include -#include - /* ACL test result. * diff --git a/include/haproxy/backend-t.h b/include/haproxy/backend-t.h index 757bb2fc3..af05cc817 100644 --- a/include/haproxy/backend-t.h +++ b/include/haproxy/backend-t.h @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include /* Parameters for lbprm.algo */ diff --git a/include/haproxy/backend.h b/include/haproxy/backend.h index 6662d59ff..5f6acaa24 100644 --- a/include/haproxy/backend.h +++ b/include/haproxy/backend.h @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include #include int assign_server(struct stream *s); diff --git a/include/haproxy/check.h b/include/haproxy/check.h index f38ba2ad4..66023ce59 100644 --- a/include/haproxy/check.h +++ b/include/haproxy/check.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include const char *get_check_status_description(short check_status); const char *get_check_status_info(short check_status); diff --git a/include/haproxy/hlua-t.h b/include/haproxy/hlua-t.h index 35a7a8178..75a475358 100644 --- a/include/haproxy/hlua-t.h +++ b/include/haproxy/hlua-t.h @@ -32,9 +32,9 @@ #include #include #include +#include #include -#include #include #define CLASS_CORE "Core" diff --git a/include/haproxy/lb_fas.h b/include/haproxy/lb_fas.h index fa2a5070c..b12831c21 100644 --- a/include/haproxy/lb_fas.h +++ b/include/haproxy/lb_fas.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include struct server *fas_get_next_server(struct proxy *p, struct server *srvtoavoid); void fas_init_server_tree(struct proxy *p); diff --git a/include/haproxy/lb_fwlc.h b/include/haproxy/lb_fwlc.h index 24c7d74ac..a598af9f3 100644 --- a/include/haproxy/lb_fwlc.h +++ b/include/haproxy/lb_fwlc.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include struct server *fwlc_get_next_server(struct proxy *p, struct server *srvtoavoid); void fwlc_init_server_tree(struct proxy *p); diff --git a/include/haproxy/lb_fwrr.h b/include/haproxy/lb_fwrr.h index 0accf0615..27b0a94e0 100644 --- a/include/haproxy/lb_fwrr.h +++ b/include/haproxy/lb_fwrr.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include void fwrr_init_server_groups(struct proxy *p); struct server *fwrr_get_next_server(struct proxy *p, struct server *srvtoavoid); diff --git a/include/haproxy/lb_map-t.h b/include/haproxy/lb_map-t.h index b2c556cab..0c45c2561 100644 --- a/include/haproxy/lb_map-t.h +++ b/include/haproxy/lb_map-t.h @@ -22,8 +22,8 @@ #ifndef _HAPROXY_LB_MAP_T_H #define _HAPROXY_LB_MAP_T_H +#include #include -#include struct lb_map { struct server **srv; /* the server map used to apply weights */ diff --git a/include/haproxy/lb_map.h b/include/haproxy/lb_map.h index 1e390f729..ca483b239 100644 --- a/include/haproxy/lb_map.h +++ b/include/haproxy/lb_map.h @@ -24,7 +24,7 @@ #include #include -#include +#include void recalc_server_map(struct proxy *px); void init_server_map(struct proxy *p); diff --git a/include/haproxy/obj_type.h b/include/haproxy/obj_type.h index 0f932dd05..d42b250a2 100644 --- a/include/haproxy/obj_type.h +++ b/include/haproxy/obj_type.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index b89fb2192..f7b099786 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -37,9 +37,9 @@ #include #include #include +#include #include #include -#include /* values for proxy->state */ enum pr_state { diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index 0cfea6a63..2263c26f3 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -27,9 +27,9 @@ #include #include #include +#include #include #include -#include extern struct proxy *proxies_list; extern struct eb_root used_proxy_id; /* list of proxy IDs in use */ diff --git a/include/haproxy/queue.h b/include/haproxy/queue.h index bded67661..ef61c0d94 100644 --- a/include/haproxy/queue.h +++ b/include/haproxy/queue.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include extern struct pool_head *pool_head_pendconn; diff --git a/include/types/server.h b/include/haproxy/server-t.h similarity index 97% rename from include/types/server.h rename to include/haproxy/server-t.h index dcf5c40cb..564619dd0 100644 --- a/include/types/server.h +++ b/include/haproxy/server-t.h @@ -1,5 +1,5 @@ /* - * include/types/server.h + * include/haproxy/server-t.h * This file defines everything related to servers. * * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu @@ -19,28 +19,28 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _TYPES_SERVER_H -#define _TYPES_SERVER_H +#ifndef _HAPROXY_SERVER_T_H +#define _HAPROXY_SERVER_T_H #include #include +#include +#include + #include +#include #include #include -#include +#include #include #include #include -#include -#include #include - -#include - -#include -#include +#include #include +#include +#include /* server states. Only SRV_ST_STOPPED indicates a down server. */ @@ -168,13 +168,11 @@ enum srv_initaddr { #define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE) #define SRV_EWGHT_MAX (SRV_UWGHT_MAX * BE_WEIGHT_SCALE) -#ifdef USE_OPENSSL /* server ssl options */ -#define SRV_SSL_O_NONE 0x0000 +#define SRV_SSL_O_NONE 0x0000 #define SRV_SSL_O_NO_TLS_TICKETS 0x0100 /* disable session resumption tickets */ -#define SRV_SSL_O_NO_REUSE 0x200 /* disable session reuse */ -#define SRV_SSL_O_EARLY_DATA 0x400 /* Allow using early data */ -#endif +#define SRV_SSL_O_NO_REUSE 0x200 /* disable session reuse */ +#define SRV_SSL_O_EARLY_DATA 0x400 /* Allow using early data */ /* log servers ring's protocols options */ enum srv_log_proto { @@ -182,9 +180,6 @@ enum srv_log_proto { SRV_LOG_PROTO_OCTET_COUNTING, // TCP frames: MSGLEN SP MSG }; -/* The server names dictionary */ -extern struct dict server_name_dict; - struct pid_list { struct list list; pid_t pid; @@ -394,7 +389,7 @@ struct srv_kw_list { struct srv_kw kw[VAR_ARRAY]; }; -#endif /* _TYPES_SERVER_H */ +#endif /* _HAPROXY_SERVER_T_H */ /* * Local variables: diff --git a/include/proto/server.h b/include/haproxy/server.h similarity index 98% rename from include/proto/server.h rename to include/haproxy/server.h index 066faebce..3d47cb02b 100644 --- a/include/proto/server.h +++ b/include/haproxy/server.h @@ -1,5 +1,5 @@ /* - * include/proto/server.h + * include/haproxy/server.h * This file defines everything related to servers. * * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu @@ -19,20 +19,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _PROTO_SERVER_H -#define _PROTO_SERVER_H +#ifndef _HAPROXY_SERVER_H +#define _HAPROXY_SERVER_H #include + #include #include #include -#include -#include -#include -#include - #include +#include +#include +#include +#include +#include __decl_thread(extern HA_SPINLOCK_T idle_conn_srv_lock); @@ -40,6 +41,7 @@ extern struct eb_root idle_conn_srv; extern struct task *idle_conn_task; extern struct task *idle_conn_cleanup[MAX_THREADS]; extern struct mt_list toremove_connections[MAX_THREADS]; +extern struct dict server_name_dict; int srv_downtime(const struct server *s); int srv_lastsession(const struct server *s); @@ -66,20 +68,6 @@ struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char struct task *srv_cleanup_idle_connections(struct task *task, void *ctx, unsigned short state); struct task *srv_cleanup_toremove_connections(struct task *task, void *context, unsigned short state); -/* increase the number of cumulated connections on the designated server */ -static inline void srv_inc_sess_ctr(struct server *s) -{ - _HA_ATOMIC_ADD(&s->counters.cum_sess, 1); - HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max, - update_freq_ctr(&s->sess_per_sec, 1)); -} - -/* set the time of last session on the designated server */ -static inline void srv_set_sess_last(struct server *s) -{ - s->counters.last_sess = now.tv_sec; -} - /* * Registers the server keyword list as a list of valid keywords for next * parsing sessions. @@ -98,20 +86,6 @@ void srv_dump_kws(char **out); */ void server_recalc_eweight(struct server *sv, int must_update); -/* returns the current server throttle rate between 0 and 100% */ -static inline unsigned int server_throttle_rate(struct server *sv) -{ - struct proxy *px = sv->proxy; - - /* when uweight is 0, we're in soft-stop so that cannot be a slowstart, - * thus the throttle is 100%. - */ - if (!sv->uweight) - return 100; - - return (100U * px->lbprm.wmult * sv->cur_eweight + px->lbprm.wdiv - 1) / (px->lbprm.wdiv * sv->uweight); -} - /* * Parses weight_str and configures sv accordingly. * Returns NULL on success, error message string otherwise. @@ -134,15 +108,6 @@ const char *server_parse_addr_change_request(struct server *sv, const char *server_parse_maxconn_change_request(struct server *sv, const char *maxconn_str); -/* - * Return true if the server has a zero user-weight, meaning it's in draining - * mode (ie: not taking new non-persistent connections). - */ -static inline int server_is_draining(const struct server *s) -{ - return !s->uweight || (s->cur_admin & SRV_ADMF_DRAIN); -} - /* Shutdown all connections of a server. The caller must pass a termination * code in , which must be one of SF_ERR_* indicating the reason for the * shutdown. @@ -185,6 +150,43 @@ void srv_clr_admin_flag(struct server *s, enum srv_admin mode); */ void srv_set_dyncookie(struct server *s); +/* increase the number of cumulated connections on the designated server */ +static inline void srv_inc_sess_ctr(struct server *s) +{ + _HA_ATOMIC_ADD(&s->counters.cum_sess, 1); + HA_ATOMIC_UPDATE_MAX(&s->counters.sps_max, + update_freq_ctr(&s->sess_per_sec, 1)); +} + +/* set the time of last session on the designated server */ +static inline void srv_set_sess_last(struct server *s) +{ + s->counters.last_sess = now.tv_sec; +} + +/* returns the current server throttle rate between 0 and 100% */ +static inline unsigned int server_throttle_rate(struct server *sv) +{ + struct proxy *px = sv->proxy; + + /* when uweight is 0, we're in soft-stop so that cannot be a slowstart, + * thus the throttle is 100%. + */ + if (!sv->uweight) + return 100; + + return (100U * px->lbprm.wmult * sv->cur_eweight + px->lbprm.wdiv - 1) / (px->lbprm.wdiv * sv->uweight); +} + +/* + * Return true if the server has a zero user-weight, meaning it's in draining + * mode (ie: not taking new non-persistent connections). + */ +static inline int server_is_draining(const struct server *s) +{ + return !s->uweight || (s->cur_admin & SRV_ADMF_DRAIN); +} + /* Puts server into maintenance mode, and propagate that status down to all * tracking servers. */ @@ -294,7 +296,7 @@ static inline int srv_add_to_idle_list(struct server *srv, struct connection *co return 0; } -#endif /* _PROTO_SERVER_H */ +#endif /* _HAPROXY_SERVER_H */ /* * Local variables: diff --git a/include/haproxy/session.h b/include/haproxy/session.h index 6b5bfffcb..c687c3907 100644 --- a/include/haproxy/session.h +++ b/include/haproxy/session.h @@ -26,9 +26,9 @@ #include #include #include +#include #include #include -#include extern struct pool_head *pool_head_session; extern struct pool_head *pool_head_sess_srv_list; diff --git a/include/types/stream.h b/include/types/stream.h index 550a7ea26..8e71049c7 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -38,11 +38,11 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/src/backend.c b/src/backend.c index 26e36ae41..e4b677aea 100644 --- a/src/backend.c +++ b/src/backend.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,6 @@ #include #include #include -#include #include #define TRACE_SOURCE &trace_strm diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 425b57c36..cdb68401a 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -25,10 +25,10 @@ #include #include #include +#include #include #include -#include #include /* Report a warning if a rule is placed after a 'tcp-request session' rule. diff --git a/src/cfgparse.c b/src/cfgparse.c index 631f10021..49ef69d69 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -76,7 +77,6 @@ #include #include #include -#include #include #include #include diff --git a/src/check.c b/src/check.c index 1adbf56e2..308a86ec3 100644 --- a/src/check.c +++ b/src/check.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/src/cli.c b/src/cli.c index 321a974e2..07d3631d6 100644 --- a/src/cli.c +++ b/src/cli.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,6 @@ #include #include #include -#include #define PAYLOAD_PATTERN "<<" diff --git a/src/dns.c b/src/dns.c index dd29d270d..8eddde947 100644 --- a/src/dns.c +++ b/src/dns.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include -#include #include struct list dns_resolvers = LIST_HEAD_INIT(dns_resolvers); diff --git a/src/fcgi-app.c b/src/fcgi-app.c index 5d7aeffc0..434fc02f0 100644 --- a/src/fcgi-app.c +++ b/src/fcgi-app.c @@ -23,13 +23,12 @@ #include #include #include +#include #include #include #include -#include - /* Global list of all FCGI applications */ static struct fcgi_app *fcgi_apps = NULL; diff --git a/src/haproxy.c b/src/haproxy.c index a9e264f37..f1478b2a3 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -107,6 +107,7 @@ #include #include #include +#include #include #include #include @@ -125,7 +126,6 @@ #include #include #include -#include #include /* array of init calls for older platforms */ diff --git a/src/hlua.c b/src/hlua.c index 1ab6f5afd..57e015cb4 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,6 @@ #include #include -#include #include /* Lua uses longjmp to perform yield or throwing errors. This diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 34577b5f5..cfcbcead9 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -26,10 +26,10 @@ #include #include #include +#include #include #include -#include #include /* Contains the class reference of the concat object. */ diff --git a/src/http_ana.c b/src/http_ana.c index c6b292e79..c0b3dd480 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,6 @@ #include -#include #include #define TRACE_SOURCE &trace_strm diff --git a/src/lb_chash.c b/src/lb_chash.c index aaaef8958..1fb44f4c7 100644 --- a/src/lb_chash.c +++ b/src/lb_chash.c @@ -16,13 +16,12 @@ * */ +#include #include #include #include +#include #include -#include - -#include /* Return next tree node after which must still be in the tree, or be * NULL. Lookup wraps around the end to the beginning. If the next node is the diff --git a/src/lb_fas.c b/src/lb_fas.c index fc9ae5182..be2ce47e1 100644 --- a/src/lb_fas.c +++ b/src/lb_fas.c @@ -16,12 +16,11 @@ * */ +#include #include #include #include -#include - -#include +#include /* Remove a server from a tree. It must have previously been dequeued. This diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index d7c695317..a835f014e 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -10,12 +10,11 @@ * */ +#include #include #include #include -#include - -#include +#include /* Remove a server from a tree. It must have previously been dequeued. This diff --git a/src/lb_fwrr.c b/src/lb_fwrr.c index 145d09784..6183433eb 100644 --- a/src/lb_fwrr.c +++ b/src/lb_fwrr.c @@ -10,12 +10,12 @@ * */ +#include #include #include #include -#include +#include -#include static inline void fwrr_remove_from_tree(struct server *s); static inline void fwrr_queue_by_weight(struct eb_root *root, struct server *s); diff --git a/src/lb_map.c b/src/lb_map.c index c963180a9..61debf838 100644 --- a/src/lb_map.c +++ b/src/lb_map.c @@ -10,13 +10,12 @@ * */ +#include #include #include #include #include -#include - -#include +#include /* this function updates the map according to server 's new state. * diff --git a/src/proto_tcp.c b/src/proto_tcp.c index c2a1869e5..4ca410009 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,6 @@ #include #include #include -#include #include static int tcp_bind_listeners(struct protocol *proto, char *errmsg, int errlen); diff --git a/src/proxy.c b/src/proxy.c index 173f17dff..12cbd4651 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include -#include #include #include diff --git a/src/queue.c b/src/queue.c index ea0b64af7..c2853a959 100644 --- a/src/queue.c +++ b/src/queue.c @@ -75,6 +75,7 @@ s * queue's lock. #include #include #include +#include #include #include #include @@ -82,7 +83,6 @@ s * queue's lock. #include #include -#include #include diff --git a/src/server.c b/src/server.c index 4751065b7..63aa6ea6c 100644 --- a/src/server.c +++ b/src/server.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,6 @@ #include #include -#include #include #include diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 3a0918f9a..4cbe2dcbf 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,6 @@ #include #include #include -#include #include /* ***** READ THIS before adding code here! ***** diff --git a/src/stats.c b/src/stats.c index 4f6f6c009..21d8dada8 100644 --- a/src/stats.c +++ b/src/stats.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,6 @@ #include #include #include -#include /* status codes available for the stats admin page (strictly 4 chars length) */ const char *stat_status_codes[STAT_STATUS_SIZE] = { diff --git a/src/stream.c b/src/stream.c index 45c1bc845..52fcf9b0a 100644 --- a/src/stream.c +++ b/src/stream.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,6 @@ #include #include #include -#include #include DECLARE_POOL(pool_head_stream, "stream", sizeof(struct stream));