Introduce nodes_lock to be used by nodes on the tree

parent 902e3af2
......@@ -37,6 +37,7 @@ struct bytes_tree {
int retval;
struct lock tree_lock;
struct lock nodes_lock;
// esi_level > 1 signalling new data
pthread_cond_t cond;
struct node *root;
......@@ -155,7 +156,7 @@ struct node_subreq {
struct boc *boc;
// oc is NULL if already transferred back into req
struct objcore *oc;
struct lock *shared_lock; // == &tree->tree_lock
struct lock *shared_lock; // == &tree->nodes_lock
pthread_cond_t cond;
// subreq to topreq delivery
int done;
......
......@@ -92,7 +92,9 @@ static void vped_close_vdp(struct req *, int, const struct vdp *);
static void assert_vdp_next_not(struct req *, const struct vdp *);
/* shared with vmod code */
struct VSC_lck *lck_bytes_tree, *lck_pesi_tasks;
struct VSC_lck *lck_bytes_tree,
*lck_bytes_nodes,
*lck_pesi_tasks;
extern struct mempool *mempool;
struct mempool *mempool = NULL;
......@@ -661,6 +663,7 @@ bytes_tree_init(struct bytes_tree *bytes_tree, struct node *root_node)
INIT_OBJ(bytes_tree, BYTES_TREE_MAGIC);
Lck_New(&bytes_tree->tree_lock, lck_bytes_tree);
Lck_New(&bytes_tree->nodes_lock, lck_bytes_nodes);
AZ(pthread_cond_init(&bytes_tree->cond, NULL));
AZ(bytes_tree->retval);
AZ(bytes_tree->npending);
......@@ -705,6 +708,7 @@ bytes_tree_fini(struct bytes_tree *bytes_tree, struct vdp_ctx *vdc)
AZ(pthread_cond_destroy(&bytes_tree->cond));
tree_free(vdc, bytes_tree->root);
Lck_Delete(&bytes_tree->nodes_lock);
}
static void
......@@ -1485,7 +1489,7 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
HSH_Ref(req->objcore);
node->subreq.oc = req->objcore;
node->subreq.shared_lock = &tree->tree_lock;
node->subreq.shared_lock = &tree->nodes_lock;
AZ(pthread_cond_init(&node->subreq.cond, NULL));
AZ(node->subreq.done);
......
......@@ -29,7 +29,9 @@
* interfaces shared between vdp_pesi.c and vmod_pesi.c
*/
extern struct VSC_lck *lck_bytes_tree, *lck_pesi_tasks;
extern struct VSC_lck *lck_bytes_tree,
*lck_bytes_nodes,
*lck_pesi_tasks;
extern const struct vdp VDP_pesi;
/* ------------------------------------------------------------
......
......@@ -350,9 +350,11 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
if (loadcnt++ == 0) {
AZ(vsc_seg);
lck_bytes_tree = Lck_CreateClass(&vsc_seg, "pesi.buf");
lck_bytes_nodes = Lck_CreateClass(&vsc_seg, "pesi.nodes");
lck_pesi_tasks = Lck_CreateClass(&vsc_seg, "pesi.tasks");
lck_stats = Lck_CreateClass(&vsc_seg, "pesi.stats");
AN(lck_bytes_tree);
AN(lck_bytes_nodes);
AN(lck_pesi_tasks);
AZ(pesi_vsc_seg);
stats = VSC_pesi_New(NULL, &pesi_vsc_seg, "");
......
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