[master] b6f0915 Use the new VSB_quote_pfx instead of hand-rolling
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jan 19 13:56:05 CET 2017
commit b6f0915b9c7079ef37247dd9aee6a9c97712634c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jan 19 12:37:50 2017 +0000
Use the new VSB_quote_pfx instead of hand-rolling
diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c
index 5ef0813..309a10b 100644
--- a/bin/varnishtest/vtc_log.c
+++ b/bin/varnishtest/vtc_log.c
@@ -196,41 +196,22 @@ vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...)
void
vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len)
{
- int nl = 1, olen;
- unsigned l;
+ char buf[64];
AN(pfx);
GET_VL(vl);
if (str == NULL)
vtc_leadin(vl, lvl, "%s(null)\n", pfx);
else {
- olen = len;
+ bprintf(buf, "%s %-4s %4.1f %s|",
+ lead[lvl < 0 ? 1: lvl], vl->id, vl->tx, pfx);
if (len < 0)
len = strlen(str);
- for (l = 0; l < len; l++, str++) {
- if (l > 1024 && olen != -2) {
- VSB_printf(vl->vsb, "...");
- break;
- }
- if (nl) {
- vtc_leadin(vl, lvl, "%s| ", pfx);
- nl = 0;
- }
- if (*str == '\r')
- VSB_printf(vl->vsb, "\\r");
- else if (*str == '\t')
- VSB_printf(vl->vsb, "\\t");
- else if (*str == '\n') {
- VSB_printf(vl->vsb, "\\n\n");
- nl = 1;
- } else if (*str < 0x20 || *str > 0x7e)
- VSB_printf(vl->vsb, "\\x%02x", (*str) & 0xff);
- else
- VSB_printf(vl->vsb, "%c", *str);
- }
+ VSB_quote_pfx(vl->vsb, buf, str,len > 1024 ? 1024 : len,
+ VSB_QUOTE_NONL);
+ if (len > 1024)
+ VSB_printf(vl->vsb, "%s [...] (%d)", buf, len - 1024);
}
- if (!nl)
- VSB_printf(vl->vsb, "\n");
REL_VL(vl);
if (lvl == 0) {
vtc_error = 2;
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 2e93365..7a2e710 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -477,7 +477,7 @@ varnish_launch(struct varnish *v)
i, fd[0].revents, fd[1].revents);
if (i == 0)
vtc_fatal(v->vl, "FAIL timeout waiting for CLI connection");
- if (fd[1].revents & POLLHUP)
+ if (fd[1].revents & POLLHUP)
vtc_fatal(v->vl, "FAIL debug pipe closed");
if (!(fd[0].revents & POLLIN))
vtc_fatal(v->vl, "FAIL CLI connection wait failure");
More information about the varnish-commit
mailing list