[master] 4442c6d7c move busyobj cancel handling to a seprate function
Dridi Boukelmoune
dridi at varni.sh
Wed Apr 10 09:38:30 UTC 2019
On Wed, Apr 10, 2019 at 11:29 AM Nils Goroll <nils.goroll at uplex.de> wrote:
>
>
> commit 4442c6d7ccc81ebade83846d832c93607f007457
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date: Sun Apr 7 18:17:52 2019 +0200
>
> move busyobj cancel handling to a seprate function
>
> diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
> index 1395f7101..0d54fd48c 100644
> --- a/bin/varnishd/cache/cache_hash.c
> +++ b/bin/varnishd/cache/cache_hash.c
> @@ -765,6 +765,35 @@ HSH_Abandon(struct objcore *oc)
> Lck_Unlock(&oh->mtx);
> }
>
> +/*---------------------------------------------------------------------
> + * Cancel a fetch when the client does not need it any more
> + */
> +
> +void
> +HSH_Cancel(struct worker *wrk, struct objcore *oc, struct boc *boc)
> +{
> + struct boc *bocref = NULL;
> +
> + if ((oc->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP)) == 0)
> + return;
> +
> + if (boc == NULL)
> + bocref = boc = HSH_RefBoc(oc);
Maybe drop a comment regarding the line above. I didn't understand the
intent on the first read.
> +
> + if (oc->flags & OC_F_HFP)
> + AN(oc->flags & OC_F_HFM);
> +
> + if (boc != NULL) {
> + HSH_Abandon(oc);
> + ObjWaitState(oc, BOS_FINISHED);
> + }
> +
> + if (bocref != NULL)
> + HSH_DerefBoc(wrk, oc);
> +
> + ObjSlim(wrk, oc);
> +}
> +
> /*---------------------------------------------------------------------
> * Unbusy an objcore when the object is completely fetched.
> */
> diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h
> index 41b7781a5..c2755dce1 100644
> --- a/bin/varnishd/cache/cache_objhead.h
> +++ b/bin/varnishd/cache/cache_objhead.h
> @@ -74,3 +74,4 @@ unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now,
> vtim_dur ttl, vtim_dur grace, vtim_dur keep);
> struct objcore *HSH_Private(const struct worker *wrk);
> void HSH_Abandon(struct objcore *oc);
> +void HSH_Cancel(struct worker *, struct objcore *, struct boc *);
> diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
> index a310cd32b..c6764e0c2 100644
> --- a/bin/varnishd/cache/cache_req_fsm.c
> +++ b/bin/varnishd/cache/cache_req_fsm.c
> @@ -404,15 +404,7 @@ cnt_transmit(struct worker *wrk, struct req *req)
>
> VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
>
> - if (req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP)) {
> - if (req->objcore->flags & OC_F_HFP)
> - AN(req->objcore->flags & OC_F_HFM);
> - if (boc != NULL) {
> - HSH_Abandon(req->objcore);
> - ObjWaitState(req->objcore, BOS_FINISHED);
> - }
> - ObjSlim(wrk, req->objcore);
> - }
> + HSH_Cancel(wrk, req->objcore, boc);
>
> if (boc != NULL)
> HSH_DerefBoc(wrk, req->objcore);
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
More information about the varnish-commit
mailing list