Commit 4ea75dc8 authored by Nils Goroll's avatar Nils Goroll

move req pointer to nexus to clarify who owns it

parent adb0e53c
......@@ -160,6 +160,7 @@ VSTAILQ_HEAD(node_head, node);
struct node_nexus {
struct node_head children;
struct objcore *oc;
struct req *req;
/* number of nodes pending under this node while state == ST_PRIVATE */
int npending_private;
/*
......@@ -202,7 +203,7 @@ struct node_subreq {
pthread_cond_t cond;
};
// XXX integrate with n_state?
// sub-state for node_final while in ST_DATA
enum fi_state {
FI_READY = 0,
FI_GO, // topreq signalling req to deliver
......@@ -227,9 +228,6 @@ struct node {
VSTAILQ_ENTRY(node) unpend;
struct node *parent;
// XXX (re)move me: the req from vdp_bytes()
struct req *req;
union {
struct node_nexus nexus; // T_NEXUS
struct node_data data; // T_DATA
......@@ -508,7 +506,7 @@ node_fini(struct req *req, struct node *node)
/* root req owned by varnish-cache */
if (node->parent == NULL)
break;
req_fini(&node->req, req->wrk);
req_fini(&node->nexus.req, req->wrk);
break;
default:
INCOMPL();
......@@ -797,7 +795,7 @@ set_delivered(struct bytes_tree *tree, struct node *node)
if (node->type == T_NEXUS &&
node->nexus.oc != NULL) {
req = tree->root->req;
req = tree->root->nexus.req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->wrk, WORKER_MAGIC);
......@@ -1010,7 +1008,7 @@ ved_task(struct worker *wrk, void *priv)
Lck_Unlock(&pesi_tree->tree->tree_lock);
break;
case T_NEXUS:
assert(node->req == req);
assert(node->nexus.req == req);
assert(node->state == ST_OPEN ||
node->state == ST_PRIVATE);
......@@ -1054,10 +1052,10 @@ ved_task(struct worker *wrk, void *priv)
if (pesi)
pesi_destroy(&pesi);
assert(req == node->req);
assert(req == node->nexus.req);
req = NULL;
req_fini(&node->req, wrk);
req_fini(&node->nexus.req, wrk);
/* turn into T_DATA node */
node_mutate_prep(pesi_tree->tree, node);
......@@ -1230,7 +1228,7 @@ vped_include(struct req *preq, const char *src, const char *host,
req->ws_req = WS_Snapshot(req->ws);
assert(node->type == T_NEXUS);
node->req = req;
node->nexus.req = req;
VSLdbgv(preq, "ved_include: attempt new thread req=%p", req);
......@@ -1347,7 +1345,7 @@ bytes_unpend_worklist(struct req *req, struct bytes_tree *tree,
CHECK_OBJ_NOTNULL(tree->front, NODE_MAGIC);
CHECK_OBJ_NOTNULL(tree->root, NODE_MAGIC);
assert(req == tree->root->req);
assert(req == tree->root->nexus.req);
assert(req->esi_level == 0);
......@@ -1742,7 +1740,9 @@ push_data(struct req *req, struct bytes_tree *tree,
}
assert (p != gzip_fini);
return (VDP_bytes(node->req, act, p, node->data.len));
AN(node->parent);
assert(node->parent->type == T_NEXUS);
return (VDP_bytes(node->parent->nexus.req, act, p, node->data.len));
}
/*
......@@ -1905,16 +1905,18 @@ pesi_buf_bytes(struct req *req, enum vdp_action act, void **priv,
CHECK_OBJ_NOTNULL(pesi->pecx, PECX_MAGIC);
parent = pesi->pecx->node;
CHECK_OBJ_NOTNULL(parent, NODE_MAGIC);
assert(parent->type == T_NEXUS);
VSLdbgv(req, "bytes_add: parent=%p front=%p",
parent, tree->front);
assert(req == parent->nexus.req);
VSLdbg(req, "bytes_add: adding data to node");
node = node_alloc();
CHECK_OBJ_NOTNULL(node, NODE_MAGIC);
node->type = T_DATA;
node->state = ST_DATA;
node->req = req;
node->data.len = len;
node->data.act = act;
......@@ -2159,9 +2161,9 @@ vdp_pesi_init(struct req *req, void **priv)
pesi_tree->tree->root = node_alloc();
CHECK_OBJ_NOTNULL(pesi_tree->tree->root, NODE_MAGIC);
pesi_tree->tree->front = pesi_tree->tree->root;
pesi_tree->tree->root->req = req;
pesi_tree->tree->root->state = ST_PRIVATE;
pesi_tree->tree->root->type = T_NEXUS;
pesi_tree->tree->root->nexus.req = req;
pesi_tree->tree->root->nexus.gzip.magic = NEXUS_GZIP_MAGIC;
VSTAILQ_INIT(&pesi_tree->tree->root->nexus.children);
Lck_New(&pesi_tree->tree->tree_lock, lck_bytes_tree);
......@@ -2663,8 +2665,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
VDP_Push(req, &VDP_pesi_buf, pesi);
AN(parent);
XXXAZ(push_vdps(req, &parent->nexus.gzip));
AZ(VDP_Push(req, &vped_to_parent, parent->req));
assert(parent->type == T_NEXUS);
AZ(push_vdps(req, &parent->nexus.gzip));
AZ(VDP_Push(req, &vped_to_parent, parent->nexus.req));
(void)VDP_DeliverObj(req);
......@@ -2678,7 +2681,7 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
VSLdbg(req, "vped_deliver: T_FINAL");
AZ(push_vdps(req, &parent->nexus.gzip));
AZ(VDP_Push(req, &vped_to_parent, parent->req));
AZ(VDP_Push(req, &vped_to_parent, parent->nexus.req));
node_mutate_prep(tree, node);
......@@ -2718,7 +2721,7 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
AZ(req->objcore->flags & OC_F_FINAL);
AZ(push_vdps(req, &parent->nexus.gzip));
AZ(VDP_Push(req, &vped_to_parent, parent->req));
AZ(VDP_Push(req, &vped_to_parent, parent->nexus.req));
node_mutate_prep(tree, node);
......@@ -2752,7 +2755,7 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
VDP_Push(req, &VDP_pesi_buf, pesi);
AZ(push_vdps(req, &parent->nexus.gzip));
AN(parent);
AZ(VDP_Push(req, &vped_to_parent, parent->req));
AZ(VDP_Push(req, &vped_to_parent, parent->nexus.req));
(void)VDP_DeliverObj(req);
......
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