Commit a0e5162d authored by Nils Goroll's avatar Nils Goroll Committed by Geoff Simmons

fix assertion failure when our vdp never ran

When VDP_DeliverObj() was not called, for example for a head request or a
return code which implies no response body, bytes_tree->npending == 0
was not true.

To avoid additional complications, we code the fact that the root node,
if used, is pending into the npending_private field which meant for this
purpose, but otherwise only accounts for nodes below it. Yet, this is
not implied anywhere, so this use case should be perfectly fine.

Also add a test for HEAD requests on an actual ESI object.

Note on possible alternatives: I do not think a solution at VDP init
time is possible because, after the vmod gets pushed from VCL, the
response status could still be changed with effects on whether or not a
response body is to be sent (e.g. changed from 200 to 204 after the VDP
is pushed). So our only chance is to handle the case when the VDP gets
called next after _init, which is just _fini.
parent bf2595d8
......@@ -239,6 +239,8 @@ client c1 {
<pre>Included file 19</pre>
After include
}
txreq -req HEAD
rxresp
}
client c1 -run
......
......@@ -705,11 +705,12 @@ vdp_pesi_init(struct req *req, void **priv)
root_node->type = T_NEXUS;
root_node->nexus.req = req;
root_node->nexus.gzip.magic = NEXUS_GZIP_MAGIC;
root_node->nexus.npending_private = 1;
VSTAILQ_INIT(&root_node->nexus.children);
Lck_New(&pesi_tree->tree->tree_lock, lck_bytes_tree);
pesi_tree->tree->npending = 1;
AZ(pthread_cond_init(&pesi_tree->tree->cond, NULL));
AZ(pesi_tree->tree->retval);
AZ(pesi_tree->tree->npending);
pesi->node = root_node;
AZ(pecx->state);
......@@ -779,7 +780,14 @@ vdp_pesi_fini(struct req *req, void **priv)
if (bytes_tree->retval) {
assert_node(bytes_tree->root, CHK_ANY);
}
else if (bytes_tree->root->nexus.npending_private == 1) {
/* our VDP has not run - e.g. HEAD request */
assert(bytes_tree->npending == 0);
assert(bytes_tree->root->state == ST_PRIVATE);
assert(bytes_tree->root->type == T_NEXUS);
}
else {
assert(bytes_tree->root->nexus.npending_private == 0);
assert(bytes_tree->npending == 0);
assert_node(bytes_tree->root, CHK_DELI);
}
......
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