mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
CLEANUP: remove trashlen
trashlen is a copy of global.tune.bufsize, so let's stop using it as a duplicate, fall back to the original bufsize, it's less confusing this way.
This commit is contained in:
parent
5f2877a7dd
commit
c919dc66a3
@ -132,7 +132,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 char *trash;
|
extern char *trash;
|
||||||
extern int trashlen;
|
|
||||||
extern char *swap_buffer;
|
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;
|
||||||
|
@ -1308,7 +1308,7 @@ static int acl_read_patterns_from_file( struct acl_keyword *aclkw,
|
|||||||
opaque = 0;
|
opaque = 0;
|
||||||
pattern = NULL;
|
pattern = NULL;
|
||||||
args[1] = "";
|
args[1] = "";
|
||||||
while (fgets(trash, trashlen, file) != NULL) {
|
while (fgets(trash, global.tune.bufsize, file) != NULL) {
|
||||||
line++;
|
line++;
|
||||||
c = trash;
|
c = trash;
|
||||||
|
|
||||||
|
@ -582,8 +582,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
global.tune.bufsize = atol(args[1]);
|
global.tune.bufsize = atol(args[1]);
|
||||||
if (global.tune.maxrewrite >= global.tune.bufsize / 2)
|
if (global.tune.maxrewrite >= global.tune.bufsize / 2)
|
||||||
global.tune.maxrewrite = global.tune.bufsize / 2;
|
global.tune.maxrewrite = global.tune.bufsize / 2;
|
||||||
trashlen = global.tune.bufsize;
|
trash = realloc(trash, global.tune.bufsize);
|
||||||
trash = realloc(trash, trashlen);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[0], "tune.maxrewrite")) {
|
else if (!strcmp(args[0], "tune.maxrewrite")) {
|
||||||
if (*(args[1]) == 0) {
|
if (*(args[1]) == 0) {
|
||||||
@ -1102,7 +1101,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
continue;
|
continue;
|
||||||
if (strcmp(kwl->kw[index].kw, args[0]) == 0) {
|
if (strcmp(kwl->kw[index].kw, args[0]) == 0) {
|
||||||
/* prepare error message just in case */
|
/* prepare error message just in case */
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"error near '%s' in '%s' section", args[0], "global");
|
"error near '%s' in '%s' section", args[0], "global");
|
||||||
rc = kwl->kw[index].parse(args, CFG_GLOBAL, NULL, NULL, file, linenum, &errmsg);
|
rc = kwl->kw[index].parse(args, CFG_GLOBAL, NULL, NULL, file, linenum, &errmsg);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@ -2929,7 +2928,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr = sample_parse_expr(args, &myidx, trash, trashlen);
|
expr = sample_parse_expr(args, &myidx, trash, global.tune.bufsize);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
Alert("parsing [%s:%d] : '%s': %s\n", file, linenum, args[0], trash);
|
Alert("parsing [%s:%d] : '%s': %s\n", file, linenum, args[0], trash);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
@ -5306,7 +5305,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
continue;
|
continue;
|
||||||
if (strcmp(kwl->kw[index].kw, args[0]) == 0) {
|
if (strcmp(kwl->kw[index].kw, args[0]) == 0) {
|
||||||
/* prepare error message just in case */
|
/* prepare error message just in case */
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"error near '%s' in %s section", args[0], cursection);
|
"error near '%s' in %s section", args[0], cursection);
|
||||||
rc = kwl->kw[index].parse(args, CFG_LISTEN, curproxy, &defproxy, file, linenum, &errmsg);
|
rc = kwl->kw[index].parse(args, CFG_LISTEN, curproxy, &defproxy, file, linenum, &errmsg);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
10
src/checks.c
10
src/checks.c
@ -238,7 +238,7 @@ static void set_server_check_status(struct server *s, short status, char *desc)
|
|||||||
|
|
||||||
int health, rise, fall, state;
|
int health, rise, fall, state;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
/* FIXME begin: calculate local version of the health/rise/fall/state */
|
/* FIXME begin: calculate local version of the health/rise/fall/state */
|
||||||
health = s->health;
|
health = s->health;
|
||||||
@ -418,7 +418,7 @@ void set_server_down(struct server *s)
|
|||||||
*/
|
*/
|
||||||
xferred = redistribute_pending(s);
|
xferred = redistribute_pending(s);
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
if (s->state & SRV_MAINTAIN) {
|
if (s->state & SRV_MAINTAIN) {
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
@ -510,7 +510,7 @@ void set_server_up(struct server *s) {
|
|||||||
*/
|
*/
|
||||||
xferred = check_for_pending(s);
|
xferred = check_for_pending(s);
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
if (old_state & SRV_MAINTAIN) {
|
if (old_state & SRV_MAINTAIN) {
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
@ -557,7 +557,7 @@ static void set_server_disabled(struct server *s) {
|
|||||||
*/
|
*/
|
||||||
xferred = redistribute_pending(s);
|
xferred = redistribute_pending(s);
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
"Load-balancing on %sServer %s/%s is disabled",
|
"Load-balancing on %sServer %s/%s is disabled",
|
||||||
@ -594,7 +594,7 @@ static void set_server_enabled(struct server *s) {
|
|||||||
*/
|
*/
|
||||||
xferred = check_for_pending(s);
|
xferred = check_for_pending(s);
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
chunk_printf(&msg,
|
chunk_printf(&msg,
|
||||||
"Load-balancing on %sServer %s/%s is enabled again",
|
"Load-balancing on %sServer %s/%s is enabled again",
|
||||||
|
@ -280,7 +280,7 @@ int conn_recv_proxy(struct connection *conn, int flag)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
len = recv(conn->t.sock.fd, trash, trashlen, MSG_PEEK);
|
len = recv(conn->t.sock.fd, trash, global.tune.bufsize, MSG_PEEK);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
@ -548,7 +548,7 @@ int conn_local_send_proxy(struct connection *conn, unsigned int flag)
|
|||||||
if (!(conn->flags & CO_FL_ADDR_TO_SET))
|
if (!(conn->flags & CO_FL_ADDR_TO_SET))
|
||||||
goto out_error;
|
goto out_error;
|
||||||
|
|
||||||
len = make_proxy_line(trash, trashlen, &conn->addr.from, &conn->addr.to);
|
len = make_proxy_line(trash, global.tune.bufsize, &conn->addr.from, &conn->addr.to);
|
||||||
if (!len)
|
if (!len)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ static void stats_sock_table_key_request(struct stream_interface *si, char **arg
|
|||||||
case STAT_CLI_O_TAB:
|
case STAT_CLI_O_TAB:
|
||||||
if (!ts)
|
if (!ts)
|
||||||
return;
|
return;
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
if (!stats_dump_table_head_to_buffer(&msg, si, px, px))
|
if (!stats_dump_table_head_to_buffer(&msg, si, px, px))
|
||||||
return;
|
return;
|
||||||
stats_dump_table_entry_to_buffer(&msg, si, px, ts);
|
stats_dump_table_entry_to_buffer(&msg, si, px, ts);
|
||||||
@ -1026,7 +1026,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return server's effective weight at the moment */
|
/* return server's effective weight at the moment */
|
||||||
snprintf(trash, trashlen, "%d (initial %d)\n", sv->uweight, sv->iweight);
|
snprintf(trash, global.tune.bufsize, "%d (initial %d)\n", sv->uweight, sv->iweight);
|
||||||
bi_putstr(si->ib, trash);
|
bi_putstr(si->ib, trash);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1495,7 +1495,7 @@ static void cli_io_handler(struct stream_interface *si)
|
|||||||
if (buffer_almost_full(si->ib->buf))
|
if (buffer_almost_full(si->ib->buf))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
break;
|
break;
|
||||||
@ -1668,7 +1668,7 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si)
|
|||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
unsigned int up;
|
unsigned int up;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
switch (si->conn.xprt_st) {
|
switch (si->conn.xprt_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
@ -1784,7 +1784,7 @@ static int stats_http_redir(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
struct session *s = si->conn.xprt_ctx;
|
struct session *s = si->conn.xprt_ctx;
|
||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
switch (si->conn.xprt_st) {
|
switch (si->conn.xprt_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
@ -1888,7 +1888,7 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri)
|
|||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
unsigned int up;
|
unsigned int up;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
switch (si->conn.xprt_st) {
|
switch (si->conn.xprt_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
@ -2258,7 +2258,7 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
|
|||||||
struct listener *l;
|
struct listener *l;
|
||||||
struct chunk msg;
|
struct chunk msg;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
switch (si->applet.ctx.stats.px_st) {
|
switch (si->applet.ctx.stats.px_st) {
|
||||||
case STAT_PX_ST_INIT:
|
case STAT_PX_ST_INIT:
|
||||||
@ -3315,7 +3315,7 @@ static int stats_dump_full_sess_to_buffer(struct stream_interface *si)
|
|||||||
extern const char *monthname[12];
|
extern const char *monthname[12];
|
||||||
char pn[INET6_ADDRSTRLEN];
|
char pn[INET6_ADDRSTRLEN];
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
sess = si->applet.ctx.sess.target;
|
sess = si->applet.ctx.sess.target;
|
||||||
|
|
||||||
if (si->applet.ctx.sess.section > 0 && si->applet.ctx.sess.uid != sess->uniq_id) {
|
if (si->applet.ctx.sess.section > 0 && si->applet.ctx.sess.uid != sess->uniq_id) {
|
||||||
@ -3569,7 +3569,7 @@ static int stats_dump_sess_to_buffer(struct stream_interface *si)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
switch (si->conn.xprt_st) {
|
switch (si->conn.xprt_st) {
|
||||||
case STAT_ST_INIT:
|
case STAT_ST_INIT:
|
||||||
@ -3790,7 +3790,7 @@ static int stats_table_request(struct stream_interface *si, bool show)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
while (si->conn.xprt_st != STAT_ST_FIN) {
|
while (si->conn.xprt_st != STAT_ST_FIN) {
|
||||||
switch (si->conn.xprt_st) {
|
switch (si->conn.xprt_st) {
|
||||||
@ -3985,7 +3985,7 @@ static int stats_dump_errors_to_buffer(struct stream_interface *si)
|
|||||||
if (unlikely(si->ib->flags & (CF_WRITE_ERROR|CF_SHUTW)))
|
if (unlikely(si->ib->flags & (CF_WRITE_ERROR|CF_SHUTW)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
chunk_init(&msg, trash, trashlen);
|
chunk_init(&msg, trash, global.tune.bufsize);
|
||||||
|
|
||||||
if (!si->applet.ctx.errors.px) {
|
if (!si->applet.ctx.errors.px) {
|
||||||
/* the function had not been called yet, let's prepare the
|
/* the function had not been called yet, let's prepare the
|
||||||
|
@ -345,7 +345,7 @@ void sig_dump_state(struct sig_handler *sh)
|
|||||||
|
|
||||||
send_log(p, LOG_NOTICE, "SIGHUP received, dumping servers states for proxy %s.\n", p->id);
|
send_log(p, LOG_NOTICE, "SIGHUP received, dumping servers states for proxy %s.\n", p->id);
|
||||||
while (s) {
|
while (s) {
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
|
"SIGHUP: Server %s/%s is %s. Conn: %d act, %d pend, %lld tot.",
|
||||||
p->id, s->id,
|
p->id, s->id,
|
||||||
(s->state & SRV_RUNNING) ? "UP" : "DOWN",
|
(s->state & SRV_RUNNING) ? "UP" : "DOWN",
|
||||||
@ -357,18 +357,18 @@ void sig_dump_state(struct sig_handler *sh)
|
|||||||
|
|
||||||
/* FIXME: those info are a bit outdated. We should be able to distinguish between FE and BE. */
|
/* FIXME: those info are a bit outdated. We should be able to distinguish between FE and BE. */
|
||||||
if (!p->srv) {
|
if (!p->srv) {
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"SIGHUP: Proxy %s has no servers. Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
"SIGHUP: Proxy %s has no servers. Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
||||||
p->id,
|
p->id,
|
||||||
p->feconn, p->beconn, p->totpend, p->nbpend, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
p->feconn, p->beconn, p->totpend, p->nbpend, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
||||||
} else if (p->srv_act == 0) {
|
} else if (p->srv_act == 0) {
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"SIGHUP: Proxy %s %s ! Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
"SIGHUP: Proxy %s %s ! Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
||||||
p->id,
|
p->id,
|
||||||
(p->srv_bck) ? "is running on backup servers" : "has no server available",
|
(p->srv_bck) ? "is running on backup servers" : "has no server available",
|
||||||
p->feconn, p->beconn, p->totpend, p->nbpend, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
p->feconn, p->beconn, p->totpend, p->nbpend, p->fe_counters.cum_conn, p->be_counters.cum_conn);
|
||||||
} else {
|
} else {
|
||||||
snprintf(trash, trashlen,
|
snprintf(trash, global.tune.bufsize,
|
||||||
"SIGHUP: Proxy %s has %d active servers and %d backup servers available."
|
"SIGHUP: Proxy %s has %d active servers and %d backup servers available."
|
||||||
" Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
" Conn: act(FE+BE): %d+%d, %d pend (%d unass), tot(FE+BE): %lld+%lld.",
|
||||||
p->id, p->srv_act, p->srv_bck,
|
p->id, p->srv_act, p->srv_bck,
|
||||||
@ -402,7 +402,7 @@ void init(int argc, char **argv)
|
|||||||
char *progname;
|
char *progname;
|
||||||
char *change_dir = NULL;
|
char *change_dir = NULL;
|
||||||
|
|
||||||
trash = malloc(trashlen);
|
trash = malloc(global.tune.bufsize);
|
||||||
|
|
||||||
/* NB: POSIX does not make it mandatory for gethostname() to NULL-terminate
|
/* NB: POSIX does not make it mandatory for gethostname() to NULL-terminate
|
||||||
* the string in case of truncation, and at least FreeBSD appears not to do
|
* the string in case of truncation, and at least FreeBSD appears not to do
|
||||||
|
24
src/peers.c
24
src/peers.c
@ -230,7 +230,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
si->applet.st0 = PEER_SESSION_GETVERSION;
|
si->applet.st0 = PEER_SESSION_GETVERSION;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PEER_SESSION_GETVERSION:
|
case PEER_SESSION_GETVERSION:
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -261,7 +261,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
si->applet.st0 = PEER_SESSION_GETHOST;
|
si->applet.st0 = PEER_SESSION_GETHOST;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PEER_SESSION_GETHOST:
|
case PEER_SESSION_GETHOST:
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -291,7 +291,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
case PEER_SESSION_GETPEER: {
|
case PEER_SESSION_GETPEER: {
|
||||||
struct peer *curpeer;
|
struct peer *curpeer;
|
||||||
char *p;
|
char *p;
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -344,7 +344,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
size_t key_size;
|
size_t key_size;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -445,7 +445,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
case PEER_SESSION_SENDSUCCESS:{
|
case PEER_SESSION_SENDSUCCESS:{
|
||||||
struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
|
struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
|
||||||
|
|
||||||
repl = snprintf(trash, trashlen, "%d\n", PEER_SESSION_SUCCESSCODE);
|
repl = snprintf(trash, global.tune.bufsize, "%d\n", PEER_SESSION_SUCCESSCODE);
|
||||||
repl = bi_putblk(si->ib, trash, repl);
|
repl = bi_putblk(si->ib, trash, repl);
|
||||||
if (repl <= 0) {
|
if (repl <= 0) {
|
||||||
if (repl == -1)
|
if (repl == -1)
|
||||||
@ -496,7 +496,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
|
struct peer_session *ps = (struct peer_session *)si->conn.xprt_ctx;
|
||||||
|
|
||||||
/* Send headers */
|
/* Send headers */
|
||||||
repl = snprintf(trash, trashlen,
|
repl = snprintf(trash, global.tune.bufsize,
|
||||||
PEER_SESSION_PROTO_NAME " 1.0\n%s\n%s %d\n%s %lu %d\n",
|
PEER_SESSION_PROTO_NAME " 1.0\n%s\n%s %d\n%s %lu %d\n",
|
||||||
ps->peer->id,
|
ps->peer->id,
|
||||||
localpeer,
|
localpeer,
|
||||||
@ -505,7 +505,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
ps->table->table->type,
|
ps->table->table->type,
|
||||||
(int)ps->table->table->key_size);
|
(int)ps->table->table->key_size);
|
||||||
|
|
||||||
if (repl >= trashlen) {
|
if (repl >= global.tune.bufsize) {
|
||||||
si->applet.st0 = PEER_SESSION_END;
|
si->applet.st0 = PEER_SESSION_END;
|
||||||
goto switchstate;
|
goto switchstate;
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
if (si->ib->flags & CF_WRITE_PARTIAL)
|
if (si->ib->flags & CF_WRITE_PARTIAL)
|
||||||
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
|
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
|
||||||
|
|
||||||
reql = bo_getline(si->ob, trash, trashlen);
|
reql = bo_getline(si->ob, trash, global.tune.bufsize);
|
||||||
if (reql <= 0) { /* closed or EOL not found */
|
if (reql <= 0) { /* closed or EOL not found */
|
||||||
if (reql == 0)
|
if (reql == 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -903,7 +903,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ts = eb32_entry(eb, struct stksess, upd);
|
ts = eb32_entry(eb, struct stksess, upd);
|
||||||
msglen = peer_prepare_datamsg(ts, ps, trash, trashlen);
|
msglen = peer_prepare_datamsg(ts, ps, trash, global.tune.bufsize);
|
||||||
if (msglen) {
|
if (msglen) {
|
||||||
/* message to buffer */
|
/* message to buffer */
|
||||||
repl = bi_putblk(si->ib, trash, msglen);
|
repl = bi_putblk(si->ib, trash, msglen);
|
||||||
@ -937,7 +937,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ts = eb32_entry(eb, struct stksess, upd);
|
ts = eb32_entry(eb, struct stksess, upd);
|
||||||
msglen = peer_prepare_datamsg(ts, ps, trash, trashlen);
|
msglen = peer_prepare_datamsg(ts, ps, trash, global.tune.bufsize);
|
||||||
if (msglen) {
|
if (msglen) {
|
||||||
/* message to buffer */
|
/* message to buffer */
|
||||||
repl = bi_putblk(si->ib, trash, msglen);
|
repl = bi_putblk(si->ib, trash, msglen);
|
||||||
@ -995,7 +995,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ts = eb32_entry(eb, struct stksess, upd);
|
ts = eb32_entry(eb, struct stksess, upd);
|
||||||
msglen = peer_prepare_datamsg(ts, ps, trash, trashlen);
|
msglen = peer_prepare_datamsg(ts, ps, trash, global.tune.bufsize);
|
||||||
if (msglen) {
|
if (msglen) {
|
||||||
/* message to buffer */
|
/* message to buffer */
|
||||||
repl = bi_putblk(si->ib, trash, msglen);
|
repl = bi_putblk(si->ib, trash, msglen);
|
||||||
@ -1015,7 +1015,7 @@ static void peer_io_handler(struct stream_interface *si)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
case PEER_SESSION_EXIT:
|
case PEER_SESSION_EXIT:
|
||||||
repl = snprintf(trash, trashlen, "%d\n", si->applet.st1);
|
repl = snprintf(trash, global.tune.bufsize, "%d\n", si->applet.st1);
|
||||||
|
|
||||||
if (bi_putblk(si->ib, trash, repl) == -1)
|
if (bi_putblk(si->ib, trash, repl) == -1)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -391,14 +391,14 @@ const char http_is_ver_token[256] = {
|
|||||||
static void http_silent_debug(int line, struct session *s)
|
static void http_silent_debug(int line, struct session *s)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
size += snprintf(trash + size, trashlen - size,
|
size += snprintf(trash + size, global.tune.bufsize - size,
|
||||||
"[%04d] req: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p o=%p sm=%d fw=%ld tf=%08x\n",
|
"[%04d] req: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p o=%p sm=%d fw=%ld tf=%08x\n",
|
||||||
line,
|
line,
|
||||||
s->si[0].state, s->si[0].fd, s->txn.req.msg_state, s->req->flags, s->req->analysers,
|
s->si[0].state, s->si[0].fd, s->txn.req.msg_state, s->req->flags, s->req->analysers,
|
||||||
s->req->buf->data, s->req->buf->size, s->req->l, s->req->w, s->req->r, s->req->buf->p, s->req->buf->o, s->req->to_forward, s->txn.flags);
|
s->req->buf->data, s->req->buf->size, s->req->l, s->req->w, s->req->r, s->req->buf->p, s->req->buf->o, s->req->to_forward, s->txn.flags);
|
||||||
write(-1, trash, size);
|
write(-1, trash, size);
|
||||||
size = 0;
|
size = 0;
|
||||||
size += snprintf(trash + size, trashlen - size,
|
size += snprintf(trash + size, global.tune.bufsize - size,
|
||||||
" %04d rep: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p o=%p sm=%d fw=%ld\n",
|
" %04d rep: p=%d(%d) s=%d bf=%08x an=%08x data=%p size=%d l=%d w=%p r=%p o=%p sm=%d fw=%ld\n",
|
||||||
line,
|
line,
|
||||||
s->si[1].state, s->si[1].fd, s->txn.rsp.msg_state, s->rep->flags, s->rep->analysers,
|
s->si[1].state, s->si[1].fd, s->txn.rsp.msg_state, s->rep->flags, s->rep->analysers,
|
||||||
@ -769,7 +769,7 @@ void perform_http_redirect(struct session *s, struct stream_interface *si)
|
|||||||
/* 1: create the response header */
|
/* 1: create the response header */
|
||||||
rdr.len = strlen(HTTP_302);
|
rdr.len = strlen(HTTP_302);
|
||||||
rdr.str = trash;
|
rdr.str = trash;
|
||||||
rdr.size = trashlen;
|
rdr.size = global.tune.bufsize;
|
||||||
memcpy(rdr.str, HTTP_302, rdr.len);
|
memcpy(rdr.str, HTTP_302, rdr.len);
|
||||||
|
|
||||||
srv = target_srv(&s->target);
|
srv = target_srv(&s->target);
|
||||||
@ -3099,7 +3099,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
|
|||||||
realm = do_stats?STATS_DEFAULT_REALM:px->id;
|
realm = do_stats?STATS_DEFAULT_REALM:px->id;
|
||||||
|
|
||||||
sprintf(trash, (txn->flags & TX_USE_PX_CONN) ? HTTP_407_fmt : HTTP_401_fmt, realm);
|
sprintf(trash, (txn->flags & TX_USE_PX_CONN) ? HTTP_407_fmt : HTTP_401_fmt, realm);
|
||||||
chunk_initlen(&msg, trash, trashlen, strlen(trash));
|
chunk_initlen(&msg, trash, global.tune.bufsize, strlen(trash));
|
||||||
txn->status = 401;
|
txn->status = 401;
|
||||||
stream_int_retnclose(req->prod, &msg);
|
stream_int_retnclose(req->prod, &msg);
|
||||||
/* on 401 we still count one error, because normal browsing
|
/* on 401 we still count one error, because normal browsing
|
||||||
@ -3207,7 +3207,7 @@ int http_process_req_common(struct session *s, struct channel *req, int an_bit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
struct chunk rdr = { .str = trash, .size = trashlen, .len = 0 };
|
struct chunk rdr = { .str = trash, .size = global.tune.bufsize, .len = 0 };
|
||||||
const char *msg_fmt;
|
const char *msg_fmt;
|
||||||
|
|
||||||
/* build redirect message */
|
/* build redirect message */
|
||||||
@ -3950,7 +3950,7 @@ int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* sr
|
|||||||
hdr_val += hdr_name_len;
|
hdr_val += hdr_name_len;
|
||||||
*hdr_val++ = ':';
|
*hdr_val++ = ':';
|
||||||
*hdr_val++ = ' ';
|
*hdr_val++ = ' ';
|
||||||
hdr_val += strlcpy2(hdr_val, srv_name, trash + trashlen - hdr_val);
|
hdr_val += strlcpy2(hdr_val, srv_name, trash + global.tune.bufsize - hdr_val);
|
||||||
http_header_add_tail2(&txn->req, &txn->hdr_idx, trash, hdr_val - trash);
|
http_header_add_tail2(&txn->req, &txn->hdr_idx, trash, hdr_val - trash);
|
||||||
|
|
||||||
if (old_o) {
|
if (old_o) {
|
||||||
@ -7654,7 +7654,7 @@ void debug_hdr(const char *dir, struct session *t, const char *start, const char
|
|||||||
if (start[max] == '\r' || start[max] == '\n')
|
if (start[max] == '\r' || start[max] == '\n')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
UBOUND(max, trashlen - len - 3);
|
UBOUND(max, global.tune.bufsize - len - 3);
|
||||||
len += strlcpy2(trash + len, start, max + 1);
|
len += strlcpy2(trash + len, start, max + 1);
|
||||||
trash[len++] = '\n';
|
trash[len++] = '\n';
|
||||||
if (write(1, trash, len) < 0) /* shut gcc warning */;
|
if (write(1, trash, len) < 0) /* shut gcc warning */;
|
||||||
|
@ -152,7 +152,7 @@ int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
|
|||||||
* - HEALTH mode without HTTP check => just send "OK"
|
* - HEALTH mode without HTTP check => just send "OK"
|
||||||
* - TCP mode from monitoring address => just close
|
* - TCP mode from monitoring address => just close
|
||||||
*/
|
*/
|
||||||
recv(cfd, trash, trashlen, MSG_DONTWAIT);
|
recv(cfd, trash, global.tune.bufsize, MSG_DONTWAIT);
|
||||||
if (p->mode == PR_MODE_HTTP ||
|
if (p->mode == PR_MODE_HTTP ||
|
||||||
(p->mode == PR_MODE_HEALTH && (p->options2 & PR_O2_CHK_ANY) == PR_O2_HTTP_CHK))
|
(p->mode == PR_MODE_HEALTH && (p->options2 & PR_O2_CHK_ANY) == PR_O2_HTTP_CHK))
|
||||||
send(cfd, "HTTP/1.0 200 OK\r\n\r\n", 19, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_MORE);
|
send(cfd, "HTTP/1.0 200 OK\r\n\r\n", 19, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_MORE);
|
||||||
|
@ -173,7 +173,7 @@ static int ssl_sock_switchctx_cbk(SSL *ssl, int *al, struct bind_conf *s)
|
|||||||
if (!servername)
|
if (!servername)
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
|
|
||||||
for (i = 0; i < trashlen; i++) {
|
for (i = 0; i < global.tune.bufsize; i++) {
|
||||||
if (!servername[i])
|
if (!servername[i])
|
||||||
break;
|
break;
|
||||||
trash[i] = tolower(servername[i]);
|
trash[i] = tolower(servername[i]);
|
||||||
@ -887,7 +887,7 @@ int ssl_sock_handshake(struct connection *conn, unsigned int flag)
|
|||||||
* TCP sockets. We first try to drain possibly pending
|
* TCP sockets. We first try to drain possibly pending
|
||||||
* data to avoid this as much as possible.
|
* data to avoid this as much as possible.
|
||||||
*/
|
*/
|
||||||
ret = recv(conn->t.sock.fd, trash, trashlen, MSG_NOSIGNAL|MSG_DONTWAIT);
|
ret = recv(conn->t.sock.fd, trash, global.tune.bufsize, MSG_NOSIGNAL|MSG_DONTWAIT);
|
||||||
goto out_error;
|
goto out_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
|
|||||||
* (which is recomputed every time since it's constant). If
|
* (which is recomputed every time since it's constant). If
|
||||||
* it is positive, it means we have to send from the start.
|
* it is positive, it means we have to send from the start.
|
||||||
*/
|
*/
|
||||||
ret = make_proxy_line(trash, trashlen, &si->ob->prod->conn.addr.from, &si->ob->prod->conn.addr.to);
|
ret = make_proxy_line(trash, global.tune.bufsize, &si->ob->prod->conn.addr.from, &si->ob->prod->conn.addr.to);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto out_error;
|
goto out_error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user