Commit 8e7b0f01 authored by Nils Goroll's avatar Nils Goroll

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
parent cb456b82
......@@ -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,6 +920,8 @@ 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),
......@@ -922,4 +929,8 @@ VCL_Init(void)
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 {
......
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