*/
xferred = redistribute_pending(s);
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"%sServer %s/%s is DOWN", s->state & SRV_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
if (s->tracked)
- chunk_printf(&msg, sizeof(trash), " via %s/%s",
+ chunk_printf(&msg, " via %s/%s",
s->tracked->proxy->id, s->tracked->id);
- chunk_printf(&msg, sizeof(trash), ", reason: %s", get_check_status_description(s->check_status));
+ chunk_printf(&msg, ", reason: %s", get_check_status_description(s->check_status));
if (s->check_status >= HCHK_STATUS_L57DATA)
- chunk_printf(&msg, sizeof(trash), ", code: %d", s->check_code);
+ chunk_printf(&msg, ", code: %d", s->check_code);
- chunk_printf(&msg, sizeof(trash), ", check duration: %lums", s->check_duration);
+ chunk_printf(&msg, ", check duration: %lums", s->check_duration);
- chunk_printf(&msg, sizeof(trash), ". %d active and %d backup servers left.%s"
+ chunk_printf(&msg, ". %d active and %d backup servers left.%s"
" %d sessions active, %d requeued, %d remaining in queue.\n",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
*/
xferred = check_for_pending(s);
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"%sServer %s/%s is UP", s->state & SRV_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
if (s->tracked)
- chunk_printf(&msg, sizeof(trash), " via %s/%s",
+ chunk_printf(&msg, " via %s/%s",
s->tracked->proxy->id, s->tracked->id);
- chunk_printf(&msg, sizeof(trash), ", reason: %s", get_check_status_description(s->check_status));
+ chunk_printf(&msg, ", reason: %s", get_check_status_description(s->check_status));
if (s->check_status >= HCHK_STATUS_L57DATA)
- chunk_printf(&msg, sizeof(trash), ", code: %d", s->check_code);
+ chunk_printf(&msg, ", code: %d", s->check_code);
- chunk_printf(&msg, sizeof(trash), ". %d active and %d backup servers online.%s"
+ chunk_printf(&msg, ". %d active and %d backup servers online.%s"
" %d sessions requeued, %d total in queue.\n",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
*/
xferred = redistribute_pending(s);
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"Load-balancing on %sServer %s/%s is disabled",
s->state & SRV_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
if (s->tracked)
- chunk_printf(&msg, sizeof(trash), " via %s/%s",
+ chunk_printf(&msg, " via %s/%s",
s->tracked->proxy->id, s->tracked->id);
- chunk_printf(&msg, sizeof(trash),". %d active and %d backup servers online.%s"
+ chunk_printf(&msg,". %d active and %d backup servers online.%s"
" %d sessions requeued, %d total in queue.\n",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
*/
xferred = check_for_pending(s);
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"Load-balancing on %sServer %s/%s is enabled again",
s->state & SRV_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
if (s->tracked)
- chunk_printf(&msg, sizeof(trash), " via %s/%s",
+ chunk_printf(&msg, " via %s/%s",
s->tracked->proxy->id, s->tracked->id);
- chunk_printf(&msg, sizeof(trash), ". %d active and %d backup servers online.%s"
+ chunk_printf(&msg, ". %d active and %d backup servers online.%s"
" %d sessions requeued, %d total in queue.\n",
s->proxy->srv_act, s->proxy->srv_bck,
(s->proxy->srv_bck && !s->proxy->srv_act) ? " Running on backup." : "",
return 0;
}
-int print_csv_header(struct chunk *msg, int size)
+int print_csv_header(struct chunk *msg)
{
- return chunk_printf(msg, size,
+ return chunk_printf(msg,
"# pxname,svname,"
"qcur,qmax,"
"scur,smax,slim,stot,"
struct chunk msg;
unsigned int up;
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
switch (s->data_state) {
case DATA_ST_INIT:
case DATA_ST_HEAD:
if (s->data_ctx.stats.flags & STAT_SHOW_STAT) {
- print_csv_header(&msg, sizeof(trash));
+ print_csv_header(&msg);
if (buffer_write_chunk(rep, &msg) >= 0)
return 0;
}
case DATA_ST_INFO:
up = (now.tv_sec - start_date.tv_sec);
if (s->data_ctx.stats.flags & STAT_SHOW_INFO) {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"Name: " PRODUCT_NAME "\n"
"Version: " HAPROXY_VERSION "\n"
"Release_date: " HAPROXY_DATE "\n"
struct chunk msg;
unsigned int up;
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
switch (s->data_state) {
case DATA_ST_INIT:
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"HTTP/1.0 200 OK\r\n"
"Cache-Control: no-cache\r\n"
"Connection: close\r\n"
(s->data_ctx.stats.flags & STAT_FMT_CSV) ? "text/plain" : "text/html");
if (uri->refresh > 0 && !(s->data_ctx.stats.flags & STAT_NO_REFRESH))
- chunk_printf(&msg, sizeof(trash), "Refresh: %d\r\n",
+ chunk_printf(&msg, "Refresh: %d\r\n",
uri->refresh);
- chunk_printf(&msg, sizeof(trash), "\r\n");
+ chunk_printf(&msg, "\r\n");
s->txn.status = 200;
if (buffer_write_chunk(rep, &msg) >= 0)
case DATA_ST_HEAD:
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
/* WARNING! This must fit in the first buffer !!! */
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<html><head><title>Statistics Report for " PRODUCT_NAME "%s%s</title>\n"
"<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">\n"
"<style type=\"text/css\"><!--\n"
uri->node_name ? uri->node_name : ""
);
} else {
- print_csv_header(&msg, sizeof(trash));
+ print_csv_header(&msg);
}
if (buffer_write_chunk(rep, &msg) >= 0)
return 0;
* become tricky if we want to support 4kB buffers !
*/
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<body><h1><a href=\"" PRODUCT_URL "\" style=\"text-decoration: none;\">"
PRODUCT_NAME "%s</a></h1>\n"
"<h2>Statistics Report for pid %d%s%s</h2>\n"
);
if (s->data_ctx.stats.flags & STAT_HIDE_DOWN)
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s%s%s\">Show all servers</a><br>\n",
uri->uri_prefix,
"",
(s->data_ctx.stats.flags & STAT_NO_REFRESH) ? ";norefresh" : "");
else
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s%s%s\">Hide 'DOWN' servers</a><br>\n",
uri->uri_prefix,
";up",
if (uri->refresh > 0) {
if (s->data_ctx.stats.flags & STAT_NO_REFRESH)
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s%s%s\">Enable refresh</a><br>\n",
uri->uri_prefix,
(s->data_ctx.stats.flags & STAT_HIDE_DOWN) ? ";up" : "",
"");
else
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s%s%s\">Disable refresh</a><br>\n",
uri->uri_prefix,
(s->data_ctx.stats.flags & STAT_HIDE_DOWN) ? ";up" : "",
";norefresh");
}
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s%s%s\">Refresh now</a><br>\n",
uri->uri_prefix,
(s->data_ctx.stats.flags & STAT_HIDE_DOWN) ? ";up" : "",
(s->data_ctx.stats.flags & STAT_NO_REFRESH) ? ";norefresh" : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<li><a href=\"%s;csv%s\">CSV export</a><br>\n",
uri->uri_prefix,
(uri->refresh > 0) ? ";norefresh" : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"</td>"
"<td align=\"left\" valign=\"top\" nowrap width=\"1%%\">"
"<b>External ressources:</b><ul style=\"margin-top: 0.25em;\">\n"
case DATA_ST_END:
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
- chunk_printf(&msg, sizeof(trash), "</body></html>\n");
+ chunk_printf(&msg, "</body></html>\n");
if (buffer_write_chunk(rep, &msg) >= 0)
return 0;
}
struct server *sv, *svs; /* server and server-state, server-state=server or server->tracked */
struct chunk msg;
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
switch (s->data_ctx.stats.px_st) {
case DATA_ST_PX_INIT:
case DATA_ST_PX_TH:
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
/* print a new table */
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<table cols=\"29\" class=\"tbl\" width=\"100%%\">\n"
"<tr align=\"center\" class=\"titre\">"
"<th colspan=2 class=\"pxname\">%s</th>"
if ((px->cap & PR_CAP_FE) &&
(!(s->data_ctx.stats.flags & STAT_BOUND) || (s->data_ctx.stats.type & (1 << STATS_TYPE_FE)))) {
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* name, queue */
"<tr align=center class=\"frontend\"><td>Frontend</td><td colspan=3></td>"
/* sessions rate : current, max, limit */
U2H3(px->feconn), U2H4(px->feconn_max), U2H5(px->maxconn),
U2H6(px->cum_feconn), U2H7(px->bytes_in), U2H8(px->bytes_out));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* denied: req, resp */
"<td align=right>%s</td><td align=right>%s</td>"
/* errors : request, connect, response */
px->state == PR_STRUN ? "OPEN" :
px->state == PR_STIDLE ? "FULL" : "STOP");
} else {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* pxid, name, queue cur, queue max, */
"%s,FRONTEND,,,"
/* sessions : current, max, limit, total */
"UP %d/%d ↓", "UP",
"NOLB %d/%d ↓", "NOLB",
"<i>no check</i>" };
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* name */
"<tr align=\"center\" class=\"%s%d\"><td>%s</td>"
/* queue : current, max, limit */
U2H5(sv->cur_sess), U2H6(sv->cur_sess_max), LIM2A7(sv->maxconn, "-"),
U2H8(sv->cum_sess), U2H9(sv->cum_lbconn));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* bytes : in, out */
"<td align=right>%s</td><td align=right>%s</td>"
/* denied: req, resp */
sv->retries, sv->redispatches);
/* status, lest check */
- chunk_printf(&msg, sizeof(trash), "<td nowrap>");
+ chunk_printf(&msg, "<td nowrap>");
if (sv->state & SRV_CHECKED) {
- chunk_printf(&msg, sizeof(trash), "%s ",
+ chunk_printf(&msg, "%s ",
human_time(now.tv_sec - sv->last_change, 1));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
srv_hlt_st[sv_state],
(svs->state & SRV_RUNNING) ? (svs->health - svs->rise + 1) : (svs->health),
(svs->state & SRV_RUNNING) ? (svs->fall) : (svs->rise));
- chunk_printf(&msg, sizeof(trash), "</td><td title=\"%s\" nowrap> %s%s",
+ chunk_printf(&msg, "</td><td title=\"%s\" nowrap> %s%s",
get_check_status_description(sv->check_status),
tv_iszero(&sv->check_start)?"":"* ",
get_check_status_info(sv->check_status));
if (sv->check_status >= HCHK_STATUS_L57DATA)
- chunk_printf(&msg, sizeof(trash), "/%d", sv->check_code);
+ chunk_printf(&msg, "/%d", sv->check_code);
if (sv->check_status >= HCHK_STATUS_CHECKED)
- chunk_printf(&msg, sizeof(trash), " in %lums", sv->check_duration);
+ chunk_printf(&msg, " in %lums", sv->check_duration);
} else {
- chunk_printf(&msg, sizeof(trash), "</td><td>");
+ chunk_printf(&msg, "</td><td>");
}
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* weight */
"</td><td>%d</td>"
/* act, bck */
/* check failures: unique, fatal, down time */
if (sv->state & SRV_CHECKED)
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<td align=right>%lld</td><td align=right>%lld</td>"
"<td nowrap align=right>%s</td>"
"",
svs->failed_checks, svs->down_trans,
human_time(srv_downtime(sv), 1));
else if (sv != svs)
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<td nowrap colspan=3>via %s/%s</td>", svs->proxy->id, svs->id);
else
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<td colspan=3></td>");
/* throttle */
now.tv_sec >= sv->last_change) {
unsigned int ratio;
ratio = MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart);
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<td>%d %%</td></tr>\n", ratio);
} else {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"<td>-</td></tr>\n");
}
} else {
"UP %d/%d,", "UP,",
"NOLB %d/%d,", "NOLB,",
"no check," };
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* pxid, name */
"%s,%s,"
/* queue : current, max */
sv->retries, sv->redispatches);
/* status */
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
srv_hlt_st[sv_state],
(sv->state & SRV_RUNNING) ? (sv->health - sv->rise + 1) : (sv->health),
(sv->state & SRV_RUNNING) ? (sv->fall) : (sv->rise));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* weight, active, backup */
"%d,%d,%d,"
"",
/* check failures: unique, fatal; last change, total downtime */
if (sv->state & SRV_CHECKED)
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"%lld,%lld,%d,%d,",
sv->failed_checks, sv->down_trans,
(int)(now.tv_sec - sv->last_change), srv_downtime(sv));
else
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
",,,,");
/* queue limit, pid, iid, sid, */
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"%s,"
"%d,%d,%d,",
LIM2A0(sv->maxqueue, ""),
now.tv_sec >= sv->last_change) {
unsigned int ratio;
ratio = MAX(1, 100 * (now.tv_sec - sv->last_change) / sv->slowstart);
- chunk_printf(&msg, sizeof(trash), "%d", ratio);
+ chunk_printf(&msg, "%d", ratio);
}
/* sessions: lbtot */
- chunk_printf(&msg, sizeof(trash), ",%lld,", sv->cum_lbconn);
+ chunk_printf(&msg, ",%lld,", sv->cum_lbconn);
/* tracked */
if (sv->tracked)
- chunk_printf(&msg, sizeof(trash), "%s/%s,",
+ chunk_printf(&msg, "%s/%s,",
sv->tracked->proxy->id, sv->tracked->id);
else
- chunk_printf(&msg, sizeof(trash), ",");
+ chunk_printf(&msg, ",");
/* type */
- chunk_printf(&msg, sizeof(trash), "%d,", STATS_TYPE_SV);
+ chunk_printf(&msg, "%d,", STATS_TYPE_SV);
/* rate */
- chunk_printf(&msg, sizeof(trash), "%u,,%u,",
+ chunk_printf(&msg, "%u,,%u,",
read_freq_ctr(&sv->sess_per_sec),
sv->sps_max);
if (sv->state & SRV_CHECKED) {
/* check_status */
- chunk_printf(&msg, sizeof(trash), "%s,", get_check_status_info(sv->check_status));
+ chunk_printf(&msg, "%s,", get_check_status_info(sv->check_status));
/* check_code */
if (sv->check_status >= HCHK_STATUS_L57DATA)
- chunk_printf(&msg, sizeof(trash), "%u,", sv->check_code);
+ chunk_printf(&msg, "%u,", sv->check_code);
else
- chunk_printf(&msg, sizeof(trash), ",");
+ chunk_printf(&msg, ",");
/* check_duration */
if (sv->check_status >= HCHK_STATUS_CHECKED)
- chunk_printf(&msg, sizeof(trash), "%lu,", sv->check_duration);
+ chunk_printf(&msg, "%lu,", sv->check_duration);
else
- chunk_printf(&msg, sizeof(trash), ",");
+ chunk_printf(&msg, ",");
} else {
- chunk_printf(&msg, sizeof(trash), ",,,");
+ chunk_printf(&msg, ",,,");
}
/* finish with EOL */
- chunk_printf(&msg, sizeof(trash), "\n");
+ chunk_printf(&msg, "\n");
}
if (buffer_write_chunk(rep, &msg) >= 0)
return 0;
if ((px->cap & PR_CAP_BE) &&
(!(s->data_ctx.stats.flags & STAT_BOUND) || (s->data_ctx.stats.type & (1 << STATS_TYPE_BE)))) {
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* name */
"<tr align=center class=\"backend\"><td>Backend</td>"
/* queue : current, max */
U2H0(px->nbpend) /* or px->totpend ? */, U2H1(px->nbpend_max),
U2H2(read_freq_ctr(&px->be_sess_per_sec)), U2H3(px->be_sps_max));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* sessions : current, max, limit, total, lbtot */
"<td align=right>%s</td><td align=right>%s</td><td align=right>%s</td>"
"<td align=right>%s</td><td align=right>%s</td>"
U2H6(px->cum_beconn), U2H7(px->cum_lbconn),
U2H8(px->bytes_in), U2H9(px->bytes_out));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* denied: req, resp */
"<td align=right>%s</td><td align=right>%s</td>"
/* errors : request, connect, response */
(px->lbprm.tot_weight * px->lbprm.wmult + px->lbprm.wdiv - 1) / px->lbprm.wdiv,
px->srv_act, px->srv_bck);
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* rest of backend: nothing, down transitions, total downtime, throttle */
"<td align=center> </td><td align=\"right\">%d</td>"
"<td align=\"right\" nowrap>%s</td>"
px->down_trans,
px->srv?human_time(be_downtime(px), 1):" ");
} else {
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
/* pxid, name */
"%s,BACKEND,"
/* queue : current, max */
case DATA_ST_PX_END:
if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
- chunk_printf(&msg, sizeof(trash), "</table><p>\n");
+ chunk_printf(&msg, "</table><p>\n");
if (buffer_write_chunk(rep, &msg) >= 0)
return 0;
if (s->ana_state != STATS_ST_REP)
return;
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
switch (s->data_state) {
case DATA_ST_INIT:
curr_sess = LIST_ELEM(s->data_ctx.sess.bref.ref, struct session *, list);
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
"%p: proto=%s",
curr_sess,
curr_sess->listener->proto->name);
(const void *)&((struct sockaddr_in *)&curr_sess->cli_addr)->sin_addr,
pn, sizeof(pn));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" src=%s:%d fe=%s be=%s srv=%s",
pn,
ntohs(((struct sockaddr_in *)&curr_sess->cli_addr)->sin_port),
(const void *)&((struct sockaddr_in6 *)(&curr_sess->cli_addr))->sin6_addr,
pn, sizeof(pn));
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" src=%s:%d fe=%s be=%s srv=%s",
pn,
ntohs(((struct sockaddr_in6 *)&curr_sess->cli_addr)->sin6_port),
break;
}
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" as=%d ts=%02x age=%s calls=%d",
curr_sess->ana_state, curr_sess->task->state,
human_time(now.tv_sec - curr_sess->logs.tv_accept.tv_sec, 1),
curr_sess->task->calls);
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" rq[f=%06xh,l=%d,an=%02xh,rx=%s",
curr_sess->req->flags,
curr_sess->req->l,
human_time(TICKS_TO_MS(curr_sess->req->rex - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
",wx=%s",
curr_sess->req->wex ?
human_time(TICKS_TO_MS(curr_sess->req->wex - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
",ax=%s]",
curr_sess->req->analyse_exp ?
human_time(TICKS_TO_MS(curr_sess->req->analyse_exp - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" rp[f=%06xh,l=%d,an=%02xh,rx=%s",
curr_sess->rep->flags,
curr_sess->rep->l,
human_time(TICKS_TO_MS(curr_sess->rep->rex - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
",wx=%s",
curr_sess->rep->wex ?
human_time(TICKS_TO_MS(curr_sess->rep->wex - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
",ax=%s]",
curr_sess->rep->analyse_exp ?
human_time(TICKS_TO_MS(curr_sess->rep->analyse_exp - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" s0=[%d,%1xh,fd=%d,ex=%s]",
curr_sess->si[0].state,
curr_sess->si[0].flags,
human_time(TICKS_TO_MS(curr_sess->si[0].exp - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" s1=[%d,%1xh,fd=%d,ex=%s]",
curr_sess->si[1].state,
curr_sess->si[1].flags,
human_time(TICKS_TO_MS(curr_sess->si[1].exp - now_ms),
TICKS_TO_MS(1000)) : "");
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" exp=%s",
curr_sess->task->expire ?
human_time(TICKS_TO_MS(curr_sess->task->expire - now_ms),
TICKS_TO_MS(1000)) : "");
if (task_in_rq(curr_sess->task))
- chunk_printf(&msg, sizeof(trash), " run(nice=%d)", curr_sess->task->nice);
+ chunk_printf(&msg, " run(nice=%d)", curr_sess->task->nice);
- chunk_printf(&msg, sizeof(trash), "\n");
+ chunk_printf(&msg, "\n");
if (buffer_write_chunk(rep, &msg) >= 0) {
/* let's try again later from this session. We add ourselves into
* continuation of a previous truncated line begin with "+" instead of " "
* after the offset. The new pointer is returned.
*/
-static int dump_error_line(struct chunk *out, int size,
- struct error_snapshot *err, int *line, int ptr)
+static int dump_error_line(struct chunk *out, struct error_snapshot *err,
+ int *line, int ptr)
{
int end;
unsigned char c;
end = out->len + 80;
- if (end > size)
+ if (end > out->size)
return ptr;
- chunk_printf(out, size, " %05d%c ", ptr, (ptr == *line) ? ' ' : '+');
+ chunk_printf(out, " %05d%c ", ptr, (ptr == *line) ? ' ' : '+');
while (ptr < err->len) {
c = err->buf[ptr];
if (s->ana_state != STATS_ST_REP)
return;
- msg.len = 0;
- msg.str = trash;
+ chunk_init(&msg, trash, sizeof(trash));
if (!s->data_ctx.errors.px) {
/* the function had not been called yet, let's prepare the
struct tm tm;
get_localtime(es->when.tv_sec, &tm);
- chunk_printf(&msg, sizeof(trash), "\n[%02d/%s/%04d:%02d:%02d:%02d.%03d]",
+ chunk_printf(&msg, "\n[%02d/%s/%04d:%02d:%02d:%02d.%03d]",
tm.tm_mday, monthname[tm.tm_mon], tm.tm_year+1900,
tm.tm_hour, tm.tm_min, tm.tm_sec, (int)(es->when.tv_usec/1000));
switch (s->data_ctx.errors.buf) {
case 0:
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" frontend %s (#%d): invalid request\n"
" src %s, session #%d, backend %s (#%d), server %s (#%d)\n"
" request length %d bytes, error at position %d:\n\n",
es->len, es->pos);
break;
case 1:
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" backend %s (#%d) : invalid response\n"
" src %s, session #%d, frontend %s (#%d), server %s (#%d)\n"
" response length %d bytes, error at position %d:\n\n",
if (s->data_ctx.errors.sid != es->sid) {
/* the snapshot changed while we were dumping it */
- chunk_printf(&msg, sizeof(trash),
+ chunk_printf(&msg,
" WARNING! update detected on this snapshot, dump interrupted. Please re-check!\n");
if (buffer_write_chunk(rep, &msg) >= 0)
return;
int newline;
newline = s->data_ctx.errors.bol;
- newptr = dump_error_line(&msg, sizeof(trash), es, &newline, s->data_ctx.errors.ptr);
+ newptr = dump_error_line(&msg, es, &newline, s->data_ctx.errors.ptr);
if (newptr == s->data_ctx.errors.ptr)
return;