transit buffer without the timeout on the condition variable

We do not need to periodically check the conditions in
obj_extend_condwait() if we ensure that HSH_Cancel() triggers a
wakeup.

Readers on private objects need to ensure they call HSH_Cancel() if
they abort the read, so this is consistent with our requirements.

While we could add a seperate function to the object API for the sole
purpose of signaling a cancel, HSH_Cancel() already calls
ObjWaitState() to syncronize with the backend thread, so adding the
signal there was deemed the simpler solution.

As agreed during bugwash, Martin wants to add back the timeout
as an optinal parameter (default: no timeout).
parent 530dc80f
......@@ -232,12 +232,8 @@ obj_extend_condwait(const struct objcore *oc)
* updates to delivered_so_far after timing out.
*/
while (!(oc->flags & OC_F_CANCEL) && oc->boc->fetched_so_far >
oc->boc->delivered_so_far + oc->boc->transit_buffer) {
(void)Lck_CondWaitTimeout(&oc->boc->cond, &oc->boc->mtx, 0.1);
/* Fallback: Check if we are alone waiting on this object */
if (oc->refcnt == 1)
break;
}
oc->boc->delivered_so_far + oc->boc->transit_buffer)
(void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx);
}
void
......@@ -334,6 +330,9 @@ ObjWaitState(const struct objcore *oc, enum boc_state_e want)
CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
Lck_Lock(&oc->boc->mtx);
/* wake up obj_extend_condwait() */
if (oc->flags & OC_F_CANCEL)
AZ(pthread_cond_signal(&oc->boc->cond));
while (1) {
if (oc->boc->state >= want)
break;
......
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