mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: buffers: Move swap_buffer into buffer.c and add deinit_buffer function
swap_buffer is a global variable only used by buffer_slow_realign. So it has been moved from global.h to buffer.c and it is allocated by init_buffer function. deinit_buffer function has been added to release it. It is also used to destroy the buffers' pool.
This commit is contained in:
parent
084aa9615b
commit
ad405f1714
@ -53,6 +53,7 @@ extern struct buffer buf_wanted;
|
|||||||
extern struct list buffer_wq;
|
extern struct list buffer_wq;
|
||||||
|
|
||||||
int init_buffer();
|
int init_buffer();
|
||||||
|
void deinit_buffer();
|
||||||
int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len);
|
int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int len);
|
||||||
int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
|
int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len);
|
||||||
void buffer_dump(FILE *o, struct buffer *b, int from, int to);
|
void buffer_dump(FILE *o, struct buffer *b, int from, int to);
|
||||||
|
@ -172,7 +172,6 @@ extern int actconn; /* # of active sessions */
|
|||||||
extern int listeners;
|
extern int listeners;
|
||||||
extern int jobs; /* # of active jobs */
|
extern int jobs; /* # of active jobs */
|
||||||
extern struct chunk trash;
|
extern struct chunk trash;
|
||||||
extern char *swap_buffer;
|
|
||||||
extern int nb_oldpids; /* contains the number of old pids found */
|
extern int nb_oldpids; /* contains the number of old pids found */
|
||||||
extern const int zero;
|
extern const int zero;
|
||||||
extern const int one;
|
extern const int one;
|
||||||
|
16
src/buffer.c
16
src/buffer.c
@ -34,6 +34,11 @@ struct buffer buf_wanted = { .p = buf_wanted.data };
|
|||||||
/* list of objects waiting for at least one buffer */
|
/* list of objects waiting for at least one buffer */
|
||||||
struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
|
struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
|
||||||
|
|
||||||
|
/* this buffer is always the same size as standard buffers and is used for
|
||||||
|
* swapping data inside a buffer.
|
||||||
|
*/
|
||||||
|
static char *swap_buffer = NULL;
|
||||||
|
|
||||||
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
|
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
|
||||||
int init_buffer()
|
int init_buffer()
|
||||||
{
|
{
|
||||||
@ -59,9 +64,20 @@ int init_buffer()
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pool_free2(pool2_buffer, buffer);
|
pool_free2(pool2_buffer, buffer);
|
||||||
|
|
||||||
|
swap_buffer = calloc(1, global.tune.bufsize);
|
||||||
|
if (swap_buffer == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deinit_buffer()
|
||||||
|
{
|
||||||
|
free(swap_buffer); swap_buffer = NULL;
|
||||||
|
pool_destroy2(pool2_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/* This function writes the string <str> at position <pos> which must be in
|
/* This function writes the string <str> at position <pos> which must be in
|
||||||
* buffer <b>, and moves <end> just after the end of <str>. <b>'s parameters
|
* buffer <b>, and moves <end> just after the end of <str>. <b>'s parameters
|
||||||
* <l> and <r> are updated to be valid after the shift. The shift value
|
* <l> and <r> are updated to be valid after the shift. The shift value
|
||||||
|
@ -177,11 +177,6 @@ static const char *old_unixsocket;
|
|||||||
|
|
||||||
static char *cur_unixsocket = NULL;
|
static char *cur_unixsocket = NULL;
|
||||||
|
|
||||||
/* this buffer is always the same size as standard buffers and is used for
|
|
||||||
* swapping data inside a buffer.
|
|
||||||
*/
|
|
||||||
char *swap_buffer = NULL;
|
|
||||||
|
|
||||||
int atexit_flag = 0;
|
int atexit_flag = 0;
|
||||||
|
|
||||||
int nb_oldpids = 0;
|
int nb_oldpids = 0;
|
||||||
@ -1723,7 +1718,6 @@ static void init(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
swap_buffer = calloc(1, global.tune.bufsize);
|
|
||||||
get_http_auth_buff = calloc(1, global.tune.bufsize);
|
get_http_auth_buff = calloc(1, global.tune.bufsize);
|
||||||
static_table_key = calloc(1, sizeof(*static_table_key));
|
static_table_key = calloc(1, sizeof(*static_table_key));
|
||||||
|
|
||||||
@ -2131,7 +2125,6 @@ void deinit(void)
|
|||||||
free(oldpids); oldpids = NULL;
|
free(oldpids); oldpids = NULL;
|
||||||
free(static_table_key); static_table_key = NULL;
|
free(static_table_key); static_table_key = NULL;
|
||||||
free(get_http_auth_buff); get_http_auth_buff = NULL;
|
free(get_http_auth_buff); get_http_auth_buff = NULL;
|
||||||
free(swap_buffer); swap_buffer = NULL;
|
|
||||||
free(global_listener_queue_task); global_listener_queue_task = NULL;
|
free(global_listener_queue_task); global_listener_queue_task = NULL;
|
||||||
|
|
||||||
list_for_each_entry_safe(log, logb, &global.logsrvs, list) {
|
list_for_each_entry_safe(log, logb, &global.logsrvs, list) {
|
||||||
@ -2153,11 +2146,12 @@ void deinit(void)
|
|||||||
|
|
||||||
vars_prune(&global.vars, NULL, NULL);
|
vars_prune(&global.vars, NULL, NULL);
|
||||||
|
|
||||||
|
deinit_buffer();
|
||||||
|
|
||||||
pool_destroy2(pool2_stream);
|
pool_destroy2(pool2_stream);
|
||||||
pool_destroy2(pool2_session);
|
pool_destroy2(pool2_session);
|
||||||
pool_destroy2(pool2_connection);
|
pool_destroy2(pool2_connection);
|
||||||
pool_destroy2(pool2_trash);
|
pool_destroy2(pool2_trash);
|
||||||
pool_destroy2(pool2_buffer);
|
|
||||||
pool_destroy2(pool2_requri);
|
pool_destroy2(pool2_requri);
|
||||||
pool_destroy2(pool2_task);
|
pool_destroy2(pool2_task);
|
||||||
pool_destroy2(pool2_capture);
|
pool_destroy2(pool2_capture);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user