Skip to content
Permalink
Browse files

add a vsl to the cli ctx if there is no msg buffer

This is another requirement for use of VRT_fail() in director context.

For code checking for (struct vrt_ctx *)->vsl the logging order now may
change, and we might want to review our VSL() calls if the ctx vsl
buffer may now be used instead.

Ref #2997
  • Loading branch information...
nigoroll committed May 15, 2019
1 parent cb456b8 commit 8e7b0f01d7c2bb0ae57c016f8bfb01d1fbd00dcb
Showing with 16 additions and 2 deletions.
  1. +11 −0 bin/varnishd/cache/cache_vcl.c
  2. +5 −2 bin/varnishtest/tests/v00041.vtc
@@ -68,6 +68,7 @@ static struct vrt_ctx ctx_cli;
static unsigned handling_cli;
static struct ws ws_cli;
static uintptr_t ws_snapshot_cli;
static struct vsl_log vsl_cli;

/*--------------------------------------------------------------------*/

@@ -127,6 +128,8 @@ VCL_Get_CliCtx(int msg)
if (msg) {
ctx_cli.msg = VSB_new_auto();
AN(ctx_cli.msg);
} else {
ctx_cli.vsl = &vsl_cli;
}
ctx_cli.ws = &ws_cli;
WS_Assert(ctx_cli.ws);
@@ -142,6 +145,8 @@ VCL_Rel_CliCtx(struct vrt_ctx **ctx)
AN((*ctx)->handling);
if (ctx_cli.msg)
VSB_destroy(&ctx_cli.msg);
if (ctx_cli.vsl)
VSL_Flush(ctx_cli.vsl, 0);
WS_Assert(ctx_cli.ws);
WS_Reset(&ws_cli, ws_snapshot_cli);
INIT_OBJ(*ctx, VRT_CTX_MAGIC);
@@ -915,11 +920,17 @@ static struct cli_proto vcl_cmds[] = {
void
VCL_Init(void)
{
unsigned sz;
char *vslbuf;

assert(cache_param->workspace_client > 0);
WS_Init(&ws_cli, "cli", malloc(cache_param->workspace_client),
cache_param->workspace_client);
ws_snapshot_cli = WS_Snapshot(&ws_cli);
CLI_AddFuncs(vcl_cmds);
Lck_New(&vcl_mtx, lck_vcl);
sz = cache_param->vsl_buffer;
vslbuf = malloc(sz);
AN(vslbuf);
VSL_Setup(&vsl_cli, vslbuf, sz);
}
@@ -106,15 +106,18 @@ logexpect l1 -v v1 -g raw -d 1 {
expect 0 = BereqHeader {^bx0: b /snafu}
expect 0 = VCL_Log ^bar

# this is not the order of events because std.log logs
# into the CLI ctx->vsl, while vmod_debug VSL() goes straight
# to the log.
expect * 0 Debug {^vcl1: VCL_EVENT_COLD}
expect * 0 CLI {^Rd vcl.discard}
expect 0 = Debug {^test_priv_task.*new.$}
expect 0 = Debug {^test_priv_task.*update.$}
expect 0 = Debug {^test_priv_task.*exists.$}
expect * = VCL_Log {^func cleaning up}
expect 0 = Debug {^test_priv_task.*exists.$}
expect 0 = VCL_Log {^obj cleaning up}
expect 0 = Debug {^priv_task_free}
expect * = VCL_Log {^func cleaning up}
expect 0 = VCL_Log {^obj cleaning up}
} -start

client c1 {

0 comments on commit 8e7b0f0

Please sign in to comment.
You can’t perform that action at this time.