Exemplo n.º 1
0
static void
pan_wrk(struct vsb *vsb, const struct worker *wrk)
{
	const char *hand;
	unsigned m, u;
	const char *p;

	VSB_printf(vsb, "worker = %p {\n", wrk);
	if (pan_already(vsb, wrk))
		return;
	VSB_indent(vsb, 2);
	VSB_printf(vsb, "stack = {0x%jx -> 0x%jx},\n",
	    (uintmax_t)wrk->stack_start, (uintmax_t)wrk->stack_end);
	pan_ws(vsb, wrk->aws);

	m = wrk->cur_method;
	VSB_printf(vsb, "VCL::method = ");
	if (m == 0) {
		VSB_printf(vsb, "none,\n");
		return;
	}
	if (!(m & 1))
		VSB_printf(vsb, "inside ");
	m &= ~1;
	hand = VCL_Method_Name(m);
	if (hand != NULL)
		VSB_printf(vsb, "%s,\n", hand);
	else
		VSB_printf(vsb, "0x%x,\n", m);

	hand = VCL_Return_Name(wrk->handling);
	if (hand != NULL)
		VSB_printf(vsb, "VCL::return = %s,\n", hand);
	else
		VSB_printf(vsb, "VCL::return = 0x%x,\n", wrk->handling);
	VSB_printf(vsb, "VCL::methods = {");
	m = wrk->seen_methods;
	p = "";
	for (u = 1; m ; u <<= 1) {
		if (m & u) {
			VSB_printf(vsb, "%s%s", p, VCL_Method_Name(u));
			m &= ~u;
			p = ", ";
		}
	}
	VSB_printf(vsb, "},\n");
	VSB_indent(vsb, -2);
	VSB_printf(vsb, "},\n");
}
Exemplo n.º 2
0
static void
pan_wrk(const struct worker *wrk)
{
	const char *hand;
	unsigned m, u;
	const char *p;

	VSB_printf(pan_vsp, "  worker = %p {\n", wrk);
	pan_ws(wrk->aws, 4);

	m = wrk->cur_method;
	VSB_printf(pan_vsp, "  VCL::method = ");
	if (m == 0) {
		VSB_printf(pan_vsp, "none,\n");
		return;
	}
	if (!(m & 1))
		VSB_printf(pan_vsp, "*");
	m &= ~1;
	hand = VCL_Method_Name(m);
	if (hand != NULL)
		VSB_printf(pan_vsp, "%s,\n", hand);
	else
		VSB_printf(pan_vsp, "0x%x,\n", m);
	hand = VCL_Return_Name(wrk->handling);
	if (hand != NULL)
		VSB_printf(pan_vsp, "  VCL::return = %s,\n", hand);
	else
		VSB_printf(pan_vsp, "  VCL::return = 0x%x,\n", wrk->handling);
	VSB_printf(pan_vsp, "  VCL::methods = {");
	m = wrk->seen_methods;
	p = "";
	for (u = 1; m ; u <<= 1) {
		if (m & u) {
			VSB_printf(pan_vsp, "%s%s", p, VCL_Method_Name(u));
			m &= ~u;
			p = ", ";
		}
	}
	VSB_printf(pan_vsp, "},\n  },\n");
}
Exemplo n.º 3
0
static void
vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
    void *specific, unsigned method, vcl_func_f *func)
{
	uintptr_t aws;
	struct vrt_ctx ctx;

	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
	INIT_OBJ(&ctx, VRT_CTX_MAGIC);
	if (req != NULL) {
		CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
		CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
		CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC);
		VCL_Req2Ctx(&ctx, req);
	}
	if (bo != NULL) {
		if (req)
			assert(method == VCL_MET_PIPE);
		CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
		CHECK_OBJ_NOTNULL(bo->vcl, VCL_MAGIC);
		VCL_Bo2Ctx(&ctx, bo);
	}
	assert(ctx.now != 0);
	ctx.syntax = ctx.vcl->conf->syntax;
	ctx.specific = specific;
	ctx.method = method;
	wrk->handling = 0;
	ctx.handling = &wrk->handling;
	aws = WS_Snapshot(wrk->aws);
	wrk->cur_method = method;
	wrk->seen_methods |= method;
	AN(ctx.vsl);
	VSLb(ctx.vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
	func(&ctx);
	VSLb(ctx.vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
	wrk->cur_method |= 1;		// Magic marker
	if (wrk->handling == VCL_RET_FAIL)
		wrk->stats->vcl_fail++;

	/*
	 * VCL/Vmods are not allowed to make permanent allocations from
	 * wrk->aws, but they can reserve and return from it.
	 */
	assert(aws == WS_Snapshot(wrk->aws));
}
Exemplo n.º 4
0
static void
pan_wrk(const struct worker *wrk)
{
	const char *hand;

	VSB_printf(pan_vsp, "  worker = %p {\n", wrk);
	pan_ws(wrk->aws, 4);

	hand = VCL_Method_Name(wrk->cur_method);
	if (hand != NULL)
		VSB_printf(pan_vsp, "  VCL::method = %s,\n", hand);
	else
		VSB_printf(pan_vsp, "  VCL::method = 0x%x,\n", wrk->cur_method);
	hand = VCL_Return_Name(wrk->handling);
	if (hand != NULL)
		VSB_printf(pan_vsp, "  VCL::return = %s,\n", hand);
	else
		VSB_printf(pan_vsp, "  VCL::return = 0x%x,\n", wrk->handling);
	VSB_printf(pan_vsp, "  },\n");
}