Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
nigoroll committed Jan 31, 2024
1 parent c096659 commit e0b164f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bin/varnishd/cache/cache_vrt_vcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ vcldir_free(struct vcldir *vdir)
FREE_OBJ(vdir);
}

static VCL_BACKEND
vcldir_surplus(struct vcldir *vdir)
{

CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC);
assert(vdir->refcnt == 1);
vdir->refcnt = 0;
vcldir_free(vdir);
return (NULL);
}

VCL_BACKEND
VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv,
const char *fmt, ...)
Expand Down Expand Up @@ -217,12 +228,9 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv,
VDI_Event(vdir->dir, VCL_EVENT_WARM);
Lck_Unlock(&vcl_mtx);

if (temp == VCL_TEMP_COOLING) {
assert(vdir->refcnt == 1);
vdir->refcnt = 0;
vcldir_free(vdir);
return (NULL);
}
if (temp == VCL_TEMP_COOLING)
return (vcldir_surplus(vdir));

if (!temp->is_warm && temp != VCL_TEMP_INIT)
WRONG("Dynamic Backends can only be added to warm VCLs");

Expand Down

0 comments on commit e0b164f

Please sign in to comment.