extern struct xprt_ops *registered_xprt[XPRT_ENTRIES];
extern struct mux_proto_list mux_proto_list;
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_connection();
-
/* I/O callback for fd-based connections. It calls the read/write handlers
* provided by the connection's sock_ops.
*/
FLT_STRM_DATA_CB_IMPL_2(strm, chn, call, ##__VA_ARGS__), \
FLT_STRM_DATA_CB_IMPL_1(strm, chn, call, ##__VA_ARGS__))
-extern struct pool_head *pool_head_filter;
-
void flt_deinit(struct proxy *p);
int flt_check(struct proxy *p);
void check_request_for_cacheability(struct stream *s, struct channel *chn);
void check_response_for_cacheability(struct stream *s, struct channel *rtr);
int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
-void init_proto_http();
int http_find_full_header2(const char *name, int len,
char *sol, struct hdr_idx *idx,
struct hdr_ctx *ctx);
extern struct pool_head *pool_head_pendconn;
-int init_pendconn();
struct pendconn *pendconn_add(struct stream *strm);
int pendconn_dequeue(struct stream *strm);
void process_srv_queue(struct server *s);
extern struct pool_head *pool_head_session;
struct session *session_new(struct proxy *fe, struct listener *li, enum obj_type *origin);
void session_free(struct session *sess);
-int init_session();
int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr);
/* Remove the refcount from the session to the tracked counters, and clear the
static const char *cache_store_flt_id = "cache store filter";
-static struct pool_head *pool_head_cache_st = NULL;
-
struct applet http_cache_applet;
struct flt_ops cache_ops;
static struct list caches = LIST_HEAD_INIT(caches);
static struct cache *tmp_cache_config = NULL;
+DECLARE_STATIC_POOL(pool_head_cache_st, "cache_st", sizeof(struct cache_st));
+
struct cache_entry *entry_exist(struct cache *cache, char *hash)
{
struct eb32_node *node;
.release = http_cache_applet_release,
};
-__attribute__((constructor))
-static void __cache_init(void)
-{
- pool_head_cache_st = create_pool("cache_st", sizeof(struct cache_st), MEM_F_SHARED);
-}
-
/* config parsers for this section */
REGISTER_CONFIG_SECTION("cache", cfg_parse_cache, cfg_post_parse_section_cache);
REGISTER_CONFIG_POSTPARSER("cache", cfg_cache_postparser);
static int wake_srv_chk(struct conn_stream *cs);
static void __event_srv_chk_r(struct conn_stream *cs);
-static struct pool_head *pool_head_email_alert = NULL;
-static struct pool_head *pool_head_tcpcheck_rule = NULL;
+DECLARE_STATIC_POOL(pool_head_email_alert, "email_alert", sizeof(struct email_alert));
+DECLARE_STATIC_POOL(pool_head_tcpcheck_rule, "tcpcheck_rule", sizeof(struct tcpcheck_rule));
static const struct check_status check_statuses[HCHK_STATUS_SIZE] = {
return 0;
}
-__attribute__((constructor))
-static void __check_init(void)
-{
- pool_head_email_alert = create_pool("email_alert", sizeof(struct email_alert), MEM_F_SHARED);
- pool_head_tcpcheck_rule = create_pool("tcpcheck_rule", sizeof(struct tcpcheck_rule), MEM_F_SHARED);
-}
-
REGISTER_POST_CHECK(start_checks);
/*
}
#if defined(USE_ZLIB) || defined(USE_SLZ)
-static struct pool_head *pool_comp_ctx = NULL;
+DECLARE_STATIC_POOL(pool_comp_ctx, "comp_ctx", sizeof(struct comp_ctx));
+
/*
* Alloc the comp_ctx
*/
slz_prepare_dist_table();
#endif
-#if defined(USE_ZLIB) || defined(USE_SLZ)
- pool_comp_ctx = create_pool("comp_ctx", sizeof(struct comp_ctx), MEM_F_SHARED);
-#endif
-
#if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM)
global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U;
#endif
#include <proto/ssl_sock.h>
#endif
-struct pool_head *pool_head_connection;
-struct pool_head *pool_head_connstream;
+DECLARE_POOL(pool_head_connection, "connection", sizeof(struct connection));
+DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream));
+
struct xprt_ops *registered_xprt[XPRT_ENTRIES] = { NULL, };
/* List head of all known muxes for PROTO */
.list = LIST_HEAD_INIT(mux_proto_list.list)
};
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_connection()
-{
- pool_head_connection = create_pool("connection", sizeof (struct connection), MEM_F_SHARED);
- if (!pool_head_connection)
- goto fail_conn;
-
- pool_head_connstream = create_pool("conn_stream", sizeof(struct conn_stream), MEM_F_SHARED);
- if (!pool_head_connstream)
- goto fail_cs;
-
- return 1;
- fail_cs:
- pool_destroy(pool_head_connection);
- pool_head_connection = NULL;
- fail_conn:
- return 0;
-}
-
/* I/O callback for fd-based connections. It calls the read/write handlers
* provided by the connection's sock_ops, which must be valid.
*/
struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list);
static THREAD_LOCAL int64_t dns_query_id_seed = 0; /* random seed */
-static struct pool_head *dns_answer_item_pool = NULL;
-static struct pool_head *dns_resolution_pool = NULL;
+
+DECLARE_STATIC_POOL(dns_answer_item_pool, "dns_answer_item", sizeof(struct dns_answer_item));
+DECLARE_STATIC_POOL(dns_resolution_pool, "dns_resolution", sizeof(struct dns_resolution));
+
static unsigned int resolution_uuid = 1;
/* Returns a pointer to the resolvers matching the id <id>. NULL is returned if
INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
-__attribute__((constructor))
-static void __dns_init(void)
-{
- dns_answer_item_pool = create_pool("dns_answer_item", sizeof(struct dns_answer_item), MEM_F_SHARED);
- dns_resolution_pool = create_pool("dns_resolution", sizeof(struct dns_resolution), MEM_F_SHARED);
-}
-
REGISTER_POST_DEINIT(dns_deinit);
REGISTER_CONFIG_POSTPARSER("dns runtime resolver", dns_finalize_config);
#include <proto/stream_interface.h>
/* Pool used to allocate filters */
-struct pool_head *pool_head_filter = NULL;
+DECLARE_STATIC_POOL(pool_head_filter, "filter", sizeof(struct filter));
static int handle_analyzer_result(struct stream *s, struct channel *chn, unsigned int an_bit, int ret);
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
-__attribute__((constructor))
-static void
-__filters_init(void)
-{
- pool_head_filter = create_pool("filter", sizeof(struct filter), MEM_F_SHARED);
-}
-
__attribute__((destructor))
static void
__filters_deinit(void)
struct flt_ops comp_ops;
-
-/* Pools used to allocate comp_state structs */
-static struct pool_head *pool_head_comp_state = NULL;
-
-static THREAD_LOCAL struct buffer tmpbuf;
-static THREAD_LOCAL struct buffer zbuf;
-static THREAD_LOCAL unsigned int buf_output;
-
struct comp_state {
struct comp_ctx *comp_ctx; /* compression context */
struct comp_algo *comp_algo; /* compression algorithm if not NULL */
int finished;
};
+/* Pools used to allocate comp_state structs */
+DECLARE_STATIC_POOL(pool_head_comp_state, "comp_state", sizeof(struct comp_state));
+
+static THREAD_LOCAL struct buffer tmpbuf;
+static THREAD_LOCAL struct buffer zbuf;
+static THREAD_LOCAL unsigned int buf_output;
+
static int select_compression_request_header(struct comp_state *st,
struct stream *s,
struct http_msg *msg);
};
INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
-
-__attribute__((constructor))
-static void
-__flt_http_comp_init(void)
-{
- pool_head_comp_state = create_pool("comp_state", sizeof(struct comp_state), MEM_F_SHARED);
-}
int curpxopts2;
/* Pools used to allocate SPOE structs */
-static struct pool_head *pool_head_spoe_ctx = NULL;
-static struct pool_head *pool_head_spoe_appctx = NULL;
+DECLARE_STATIC_POOL(pool_head_spoe_ctx, "spoe_ctx", sizeof(struct spoe_context));
+DECLARE_STATIC_POOL(pool_head_spoe_appctx, "spoe_appctx", sizeof(struct spoe_appctx));
struct flt_ops spoe_ops;
INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_action_kws);
-__attribute__((constructor))
-static void __spoe_init(void)
-{
- pool_head_spoe_ctx = create_pool("spoe_ctx", sizeof(struct spoe_context), MEM_F_SHARED);
- pool_head_spoe_appctx = create_pool("spoe_appctx", sizeof(struct spoe_appctx), MEM_F_SHARED);
-}
-
__attribute__((destructor))
static void
__spoe_deinit(void)
exit(1);
init_task();
init_stream();
- init_session();
- init_connection();
/* warning, we init buffers later */
- init_pendconn();
if (!init_http(&err_msg)) {
ha_alert("%s. Aborting.\n", err_msg);
free(err_msg);
abort();
}
- init_proto_http();
/* Initialise lua. */
hlua_init();
/* This is the memory pool containing struct lua for applets
* (including cli).
*/
-struct pool_head *pool_head_hlua;
+DECLARE_STATIC_POOL(pool_head_hlua, "hlua", sizeof(struct hlua));
/* Used for Socket connection. */
static struct proxy socket_proxy;
};
#endif
- /* Initialise struct hlua and com signals pool */
- pool_head_hlua = create_pool("hlua", sizeof(struct hlua), MEM_F_SHARED);
-
/* Init main lua stack. */
gL.Mref = LUA_REFNIL;
gL.flags = 0;
};
/* the h1c and h1s pools */
-static struct pool_head *pool_head_h1c;
-static struct pool_head *pool_head_h1s;
+DECLARE_STATIC_POOL(pool_head_h1c, "h1c", sizeof(struct h1c));
+DECLARE_STATIC_POOL(pool_head_h1s, "h1s", sizeof(struct h1s));
static int h1_recv(struct h1c *h1c);
static int h1_send(struct h1c *h1c);
pool_destroy(pool_head_h1s);
}
-__attribute__((constructor))
-static void __h1_init(void)
-{
- pool_head_h1c = create_pool("h1c", sizeof(struct h1c), MEM_F_SHARED);
- pool_head_h1s = create_pool("h1s", sizeof(struct h1s), MEM_F_SHARED);
-}
-
REGISTER_POST_DEINIT(__h1_deinit);
/*
static const struct h2s *h2_closed_stream;
static const struct h2s *h2_idle_stream;
-/* the h2c connection pool */
-static struct pool_head *pool_head_h2c;
-/* the h2s stream pool */
-static struct pool_head *pool_head_h2s;
-
/* Connection flags (32 bit), in h2c->flags */
#define H2_CF_NONE 0x00000000
uint8_t ff; /* frame flags */
};
+/* the h2c connection pool */
+DECLARE_STATIC_POOL(pool_head_h2c, "h2c", sizeof(struct h2c));
+
+/* the h2s stream pool */
+DECLARE_STATIC_POOL(pool_head_h2s, "h2s", sizeof(struct h2s));
+
/* a few settings from the global section */
static int h2_settings_header_table_size = 4096; /* initial value */
static int h2_settings_initial_window_size = 65535; /* initial value */
pool_destroy(pool_head_h2c);
}
-__attribute__((constructor))
-static void __h2_init(void)
-{
- pool_head_h2c = create_pool("h2c", sizeof(struct h2c), MEM_F_SHARED);
- pool_head_h2s = create_pool("h2s", sizeof(struct h2s), MEM_F_SHARED);
-}
-
REGISTER_POST_DEINIT(__h2_deinit);
#include <proto/stream.h>
#include <proto/task.h>
-static struct pool_head *pool_head_pt_ctx;
-
struct mux_pt_ctx {
struct conn_stream *cs;
struct connection *conn;
struct wait_event wait_event;
};
+DECLARE_STATIC_POOL(pool_head_pt_ctx, "mux_pt", sizeof(struct mux_pt_ctx));
+
static void mux_pt_destroy(struct mux_pt_ctx *ctx)
{
struct connection *conn = ctx->conn;
{ .token = IST(""), .mode = PROTO_MODE_ANY, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt);
-
-__attribute__((constructor))
-static void __mux_pt_init(void)
-{
- pool_head_pt_ctx = create_pool("mux_pt", sizeof(struct mux_pt_ctx),
- MEM_F_SHARED);
-}
#include <types/global.h>
#include <types/pipe.h>
-struct pool_head *pool_head_pipe = NULL;
+DECLARE_STATIC_POOL(pool_head_pipe, "pipe", sizeof(struct pipe));
+
struct pipe *pipes_live = NULL; /* pipes which are still ready to use */
__decl_spinlock(pipes_lock); /* lock used to protect pipes list */
int pipes_used = 0; /* # of pipes in use (2 fds each) */
int pipes_free = 0; /* # of pipes unused */
-/* allocate memory for the pipes */
-static void init_pipe()
-{
- pool_head_pipe = create_pool("pipe", sizeof(struct pipe), MEM_F_SHARED);
-}
-
/* return a pre-allocated empty pipe. Try to allocate one if there isn't any
* left. NULL is returned if a pipe could not be allocated.
*/
HA_SPIN_UNLOCK(PIPES_LOCK, &pipes_lock);
}
-
-__attribute__((constructor))
-static void __pipe_module_init(void)
-{
- init_pipe();
-}
-
/*
* Local variables:
* c-indent-level: 8
[STAT_STATUS_UNKN] = "UNKN",
};
-void init_proto_http()
-{
- /* memory allocations */
- pool_head_http_txn = create_pool("http_txn", sizeof(struct http_txn), MEM_F_SHARED);
- pool_head_uniqueid = create_pool("uniqueid", UNIQUEID_LEN, MEM_F_SHARED);
-}
-
/*
* Adds a header and its CRLF at the tail of the message's buffer, just before
* the last CRLF. <len> bytes are copied, not counting the CRLF.
extern const char sess_term_cond[8];
extern const char sess_fin_state[8];
extern const char *monthname[12];
-struct pool_head *pool_head_http_txn;
-struct pool_head *pool_head_requri;
+
+DECLARE_POOL(pool_head_http_txn, "http_txn", sizeof(struct http_txn));
+DECLARE_POOL(pool_head_uniqueid, "uniqueid", UNIQUEID_LEN);
+
+struct pool_head *pool_head_requri = NULL;
struct pool_head *pool_head_capture = NULL;
-struct pool_head *pool_head_uniqueid;
/*
* Capture headers from message starting at <som> according to header list
http_msg_move_end(&txn->rsp, delta);
}
-__attribute__((constructor))
-static void __http_protocol_init(void)
-{
-}
-
-
/*
* Local variables:
* c-indent-level: 8
#define KEY_CLASS_OFFSET_BOUNDARY(key) (KEY_CLASS(key) | NOW_OFFSET_BOUNDARY())
#define MAKE_KEY(class, offset) (((u32)(class + 0x7ff) << 20) | ((u32)(now_ms + offset) & 0xfffff))
-struct pool_head *pool_head_pendconn;
-
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_pendconn()
-{
- pool_head_pendconn = create_pool("pendconn", sizeof(struct pendconn), MEM_F_SHARED);
- return pool_head_pendconn != NULL;
-}
+DECLARE_POOL(pool_head_pendconn, "pendconn", sizeof(struct pendconn));
/* returns the effective dynamic maxconn for a server, considering the minconn
* and the proxy's usage relative to its dynamic connections limit. It is
#include <proto/tcp_rules.h>
#include <proto/vars.h>
-struct pool_head *pool_head_session;
+DECLARE_POOL(pool_head_session, "session", sizeof(struct session));
static int conn_complete_session(struct connection *conn);
static struct task *session_expire_embryonic(struct task *t, void *context, unsigned short state);
session_free(conn->owner);
}
-/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_session()
-{
- pool_head_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
- return pool_head_session != NULL;
-}
-
/* count a new session to keep frontend, listener and track stats up to date */
static void session_count_new(struct session *sess)
{
int signal_queue_len; /* length of signal queue, <= MAX_SIGNAL (1 entry per signal max) */
int signal_queue[MAX_SIGNAL]; /* in-order queue of received signals */
struct signal_descriptor signal_state[MAX_SIGNAL];
-struct pool_head *pool_head_sig_handlers = NULL;
sigset_t blocked_sig;
int signal_pending = 0; /* non-zero if t least one signal remains unprocessed */
+DECLARE_POOL(pool_head_sig_handlers, "sig_handlers", sizeof(struct sig_handler));
/* Common signal handler, used by all signals. Received signals are queued.
* Signal number zero has a specific status, as it cannot be delivered by the
for (sig = 0; sig < MAX_SIGNAL; sig++)
LIST_INIT(&signal_state[sig].handlers);
- pool_head_sig_handlers = create_pool("sig_handlers", sizeof(struct sig_handler), MEM_F_SHARED);
- return pool_head_sig_handlers != NULL;
+ return 1;
}
/*
#include <proto/tcp_rules.h>
#include <proto/vars.h>
-struct pool_head *pool_head_stream;
+DECLARE_POOL(pool_head_stream, "stream", sizeof(struct stream));
+
struct list streams;
__decl_spinlock(streams_lock);
int init_stream()
{
LIST_INIT(&streams);
- pool_head_stream = create_pool("stream", sizeof(struct stream), MEM_F_SHARED);
- return pool_head_stream != NULL;
+
+ return 1;
}
void stream_process_counters(struct stream *s)
#include <proto/task.h>
#include <proto/fd.h>
-struct pool_head *pool_head_task;
-struct pool_head *pool_head_tasklet;
+DECLARE_POOL(pool_head_task, "task", sizeof(struct task));
+DECLARE_POOL(pool_head_tasklet, "tasklet", sizeof(struct tasklet));
/* This is the memory pool containing all the signal structs. These
* struct are used to store each required signal between two tasks.
*/
-struct pool_head *pool_head_notification;
+DECLARE_POOL(pool_head_notification, "notification", sizeof(struct notification));
unsigned int nb_tasks = 0;
volatile unsigned long active_tasks_mask = 0; /* Mask of threads with active tasks */
for (i = 0; i < MAX_THREADS; i++) {
LIST_INIT(&task_per_thread[i].task_list);
}
- pool_head_task = create_pool("task", sizeof(struct task), MEM_F_SHARED);
- if (!pool_head_task)
- return 0;
- pool_head_tasklet = create_pool("tasklet", sizeof(struct tasklet), MEM_F_SHARED);
- if (!pool_head_tasklet)
- return 0;
- pool_head_notification = create_pool("notification", sizeof(struct notification), MEM_F_SHARED);
- if (!pool_head_notification)
- return 0;
return 1;
}
#include <proto/vars.h>
/* This contains a pool of struct vars */
-static struct pool_head *var_pool = NULL;
+DECLARE_STATIC_POOL(var_pool, "vars", sizeof(struct var));
/* This array contain all the names of all the HAProxy vars.
* This permits to identify two variables name with
}};
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
-
-__attribute__((constructor))
-static void __vars_init(void)
-{
- var_pool = create_pool("vars", sizeof(struct var), MEM_F_SHARED);
-}