r778 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

Poul-Henning Kamp phk at phk.freebsd.dk
Wed Aug 9 13:47:33 CEST 2006

In message <ujrejvq5eb2.fsf at cat.linpro.no>, Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= writes:
>"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
>> Dag-Erling Smørgrav <des at projects.linpro.no> writes:
>> > void
>> > VRT_l_req_backend(struct sess *sp, struct backend *be)
>> > {
>> >         sp->backend = be;
>> > }
>> This is only good while you hold a VCL reference, so please
>> clear the field when we hit state DONE in cache_center.c at the
>> same time we let go of the VCL reference.
>Can you explain that in a little more detail please?

The backend structure belongs to the VCL code, when you 
unload a VCL program, the backend will also disappear.

While we process a request, the session hold a refcount
on the VCL program so you cannot unload it while the
VCL program is being used.

I have generally tried to take care to NULL pointers that
could risk dangling, and I'd like this also in this case
so what's needed is:

static int
cnt_done(struct sess *sp)
        double dh, dp, da;
        struct timespec te;

        assert(sp->obj == NULL);
        assert(sp->vbc == NULL);
        if (sp->fd >= 0 && sp->doclose != NULL)
                vca_close_session(sp, sp->doclose);
>>>	sp->backend = NULL;
        sp->vcl = NULL;

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the varnish-commit mailing list