Permalink
Browse files

do not unlock oh before the waitinglist setup is complete

The moment we unlock the oh, another thread could rush req

Partially undoes f35b86b

Huge thank you to @mbgrydeland for spotting my mistake
  • Loading branch information...
nigoroll committed Dec 5, 2018
1 parent 70977c3 commit d49ade4c3d229c9a4d3eb60791f95ffb837e7e18
Showing with 3 additions and 2 deletions.
  1. +3 −2 bin/varnishd/cache/cache_hash.c
@@ -522,11 +522,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
/* There are one or more busy objects, wait for them */
VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list);
Lck_Unlock(&oh->mtx);
AZ(req->hash_ignore_busy);
wrk->stats->busy_sleep++;
/*
* The objhead reference transfers to the sess, we get it
* back when the sess comes off the waiting list and
@@ -539,6 +537,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
if (DO_DEBUG(DBG_WAITINGLIST))
VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh);
Lck_Unlock(&oh->mtx);
wrk->stats->busy_sleep++;
return (HSH_BUSY);
}

0 comments on commit d49ade4

Please sign in to comment.