Factor out waiting for a subreq

parent 39fe0933
......@@ -566,6 +566,17 @@ subreq_fixup(struct node *node, struct req *req)
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)
*
......@@ -714,14 +725,9 @@ push_subreq(struct req *req, struct bytes_tree *tree,
assert(node->type == T_SUBREQ);
(void) next;
if (node->subreq.done == 0) {
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);
}
if (node->subreq.done == 0)
subreq_wait_done(node);
AN(node->subreq.done);
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