refactor out root_node_init

parent 33a73ce8
......@@ -654,7 +654,7 @@ static const struct vdp VDP_pesi_buf = {
*/
static void
bytes_tree_init(struct bytes_tree *bytes_tree)
bytes_tree_init(struct bytes_tree *bytes_tree, struct node *root_node)
{
AN(bytes_tree);
......@@ -664,6 +664,9 @@ bytes_tree_init(struct bytes_tree *bytes_tree)
AZ(pthread_cond_init(&bytes_tree->cond, NULL));
AZ(bytes_tree->retval);
AZ(bytes_tree->npending);
bytes_tree->front = root_node;
bytes_tree->root = root_node;
}
static void
......@@ -704,6 +707,20 @@ bytes_tree_fini(struct bytes_tree *bytes_tree, struct vdp_ctx *vdc)
tree_free(vdc, bytes_tree->root);
}
static void
root_node_init(struct node *root_node, struct req *req)
{
CHECK_OBJ_NOTNULL(root_node, NODE_MAGIC);
root_node->state = ST_PRIVATE;
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);
}
/* ------------------------------------------------------------
* process ESI objects from storage
*/
......@@ -762,7 +779,6 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
"parallel ESI tree data");
return (-1);
}
bytes_tree_init(pesi_tree->bytes_tree);
Lck_New(&pesi_tree->task_lock, lck_pesi_tree);
AZ(pthread_cond_init(&pesi_tree->task_cond, NULL));
......@@ -780,15 +796,11 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
*priv = pesi;
node_fill_nodestock(req->ws, &pesi->nodestock);
pesi_tree->bytes_tree->front = pesi_tree->bytes_tree->root = root_node =
node_alloc(pesi);
CHECK_OBJ_NOTNULL(root_node, NODE_MAGIC);
root_node->state = ST_PRIVATE;
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);
root_node = node_alloc(pesi);
root_node_init(root_node, req);
bytes_tree_init(pesi_tree->bytes_tree, root_node);
pesi->node = root_node;
AZ(pecx->state);
......
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