Factor out waiting for a subreq

parent 39fe0933
...@@ -566,6 +566,17 @@ subreq_fixup(struct node *node, struct req *req) ...@@ -566,6 +566,17 @@ subreq_fixup(struct node *node, struct req *req)
return (subreq); return (subreq);
} }
static void
subreq_wait_done(struct node *node)
{
Lck_Lock(node->subreq.shared_lock);
if (node->subreq.done == 0)
AZ(Lck_CondWait(
&node->subreq.cond,
node->subreq.shared_lock));
Lck_Unlock(node->subreq.shared_lock);
}
/* ------------------------------------------------------------ /* ------------------------------------------------------------
* node cleanup (not holding tree lock) * node cleanup (not holding tree lock)
* *
...@@ -714,14 +725,9 @@ push_subreq(struct req *req, struct bytes_tree *tree, ...@@ -714,14 +725,9 @@ push_subreq(struct req *req, struct bytes_tree *tree,
assert(node->type == T_SUBREQ); assert(node->type == T_SUBREQ);
(void) next; (void) next;
if (node->subreq.done == 0) { if (node->subreq.done == 0)
Lck_Lock(node->subreq.shared_lock); subreq_wait_done(node);
if (node->subreq.done == 0) AN(node->subreq.done);
AZ(Lck_CondWait(
&node->subreq.cond,
node->subreq.shared_lock));
Lck_Unlock(node->subreq.shared_lock);
}
subreq = subreq_fixup(node, req); subreq = subreq_fixup(node, 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