Introduce nodes_lock to be used by nodes on the tree

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