Commit afa9a185 authored by Nils Goroll's avatar Nils Goroll

fix %h formatter

Our %h formatter was broken and we did not notice due to coincidence of
two reasons:

Before 626ddb029256513b6de36d5e642299d6708d638d in varnish-cache,
varnishncsa did not output %h for our (ancient) test file because it
does not contain BackendStart records.

varnishevent did not output %h because it was using SLT_Backend, which
had been removed from varnish-cache for long.

Because both matched, we did not notice any issue.

It is only now due to the change from
626ddb029256513b6de36d5e642299d6708d638d that we noticed the issue.

So the fix is to take %h from SLT_BackendOpen and adjust all other test
details in this regard.

The fix in varnish triggered the ncsa.sh test failing because
varnishevent would also not format %h correctly: SLT_Backend had been
retired for long, but we still took %h from it.
parent a6ac776e
......@@ -375,7 +375,7 @@ void
format_h_backend(const tx_t *tx, const arg_t *args, char **s, size_t *len)
{
(void) args;
format_h(tx, SLT_Backend, 2, s, len);
format_h(tx, SLT_BackendOpen, 2, s, len);
}
static inline void
......@@ -1103,7 +1103,7 @@ compile_fmt(char * const format, compiled_fmt_t * const fmt,
case 'h':
add_formatter(fmt, os, n, FMT(type, format_h));
add_cb_tag(type, SLT_ReqStart, SLT_Backend, NULL);
add_cb_tag(type, SLT_ReqStart, SLT_BackendOpen, NULL);
n++;
break;
......
......@@ -709,7 +709,7 @@ static const char
printf("... testing format_h_*()\n");
reset_tag2idx(NTAGS, SLT_ReqStart, SLT_Backend);
reset_tag2idx(NTAGS, SLT_ReqStart, SLT_BackendOpen);
MASSERT(max_idx == NTAGS);
init_tx_arg(&tx, node, nptr, &args);
......@@ -719,11 +719,11 @@ static const char
MASSERT(strncmp(str, "127.0.0.1", 9) == 0);
MASSERT(len == 9);
#define BACKEND_PAYLOAD "14 default default(127.0.0.1,,80)"
add_record_data(&tx, SLT_Backend, &rec2, &c2, BACKEND_PAYLOAD);
#define BACKEND_PAYLOAD "14 default 127.0.0.1 80 127.0.0.1 1234"
add_record_data(&tx, SLT_BackendOpen, &rec2, &c2, BACKEND_PAYLOAD);
format_h_backend(&tx, &args, &str, &len);
MASSERT(strncmp(str, "default(127.0.0.1,,80)", 22) == 0);
MASSERT(len == 22);
MASSERT(strncmp(str, "127.0.0.1", 9) == 0);
MASSERT(len == 9);
return NULL;
#undef NTAGS
......@@ -1854,7 +1854,7 @@ setup_full_backend_tx(tx_t *tx, rec_node_t node[], rec_node_t *nptr[],
init_hdr_recs(tx, SLT_Timestamp);
set_hdr_data(tx, &rec[0], &c[0], get_hdr_idx(SLT_Timestamp, "Start:"),
SLT_Timestamp, T1);
add_record_data(tx, SLT_Backend, &rec[1], &c[1], BACKEND_PAYLOAD);
add_record_data(tx, SLT_BackendOpen, &rec[1], &c[1], BACKEND_PAYLOAD);
add_record_data(tx, SLT_BereqMethod, &rec[2], &c[2], "GET");
add_record_data(tx, SLT_BereqURL, &rec[3], &c[3], URL_QUERY_PAYLOAD);
add_record_data(tx, SLT_BereqProtocol, &rec[4], &c[4], PROTOCOL_PAYLOAD);
......@@ -2103,7 +2103,7 @@ static const char
case SLT_BerespStatus:
ASSERT_TAG_NOHDR(i);
break;
case SLT_Backend:
case SLT_BackendOpen:
ASSERT_TAG_NOHDR(i);
break;
case SLT_BereqAcct:
......@@ -2135,7 +2135,7 @@ static const char
setup_full_backend_tx(&tx, node, nptr, rec, c);
os = FMT_Format(&tx, &len);
#define EXP_FULL_BACKEND_OUTPUT "105 b 15703 HTTP/1.1 default(127.0.0.1,,80) "\
#define EXP_FULL_BACKEND_OUTPUT "105 b 15703 HTTP/1.1 127.0.0.1 "\
"60 foohdr barhdr - GET 283 bar=baz&quux=wilco GET "\
"http://foobar.com/foo?bar=baz&quux=wilco HTTP/1.1 200 "\
"[%d/%b/%Y:%T %z] 0 %F-%T.529143 /foo varnish 0.002837 logload "\
......@@ -2227,7 +2227,7 @@ static const char
case SLT_BerespStatus:
ASSERT_TAG_NOHDR(i);
break;
case SLT_Backend:
case SLT_BackendOpen:
ASSERT_TAG_NOHDR(i);
break;
case SLT_BereqAcct:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment