[6.0] e4534f792 Store VSC exposed state per segment
Martin Blix Grydeland
martin at varnish-software.com
Fri Oct 18 13:23:08 UTC 2019
commit e4534f792b576b377e8a743877c896b0f4ff1ce6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Fri Aug 2 14:26:03 2019 +0200
Store VSC exposed state per segment
This moves the exposed flag handling to the segment level, rather than the
point level. This enables not having to iterate over each point when there
is no change from the previous.
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index ce63dcb7e..83c83136d 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -62,7 +62,6 @@ VTAILQ_HEAD(vsc_sf_head, vsc_sf);
struct vsc_pt {
struct VSC_point point;
char *name;
- int exposed;
};
struct vsc_seg {
@@ -77,6 +76,7 @@ struct vsc_seg {
unsigned npoints;
struct vsc_pt *points;
+ int exposed;
};
struct vsc {
@@ -367,26 +367,31 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp)
*/
static void
-vsc_expose(const struct vsc *vsc, const struct vsc_seg *sp, int del)
+vsc_expose(const struct vsc *vsc, struct vsc_seg *sp, int del)
{
struct vsc_pt *pp;
unsigned u;
+ int expose;
+
+ if (vsc->fnew != NULL && !sp->exposed &&
+ !del && sp->head->ready == 1)
+ expose = 1;
+ else if (vsc->fdestroy != NULL && sp->exposed &&
+ (del || sp->head->ready == 2))
+ expose = 0;
+ else
+ return;
pp = sp->points;
for (u = 0; u < sp->npoints; u++, pp++) {
if (pp->name == NULL)
continue;
- if (vsc->fdestroy != NULL && pp->exposed &&
- (del || sp->head->ready == 2)) {
- vsc->fdestroy(vsc->priv, &pp->point);
- pp->exposed = 0;
- }
- if (vsc->fnew != NULL && !pp->exposed &&
- !del && sp->head->ready == 1) {
+ if (expose)
pp->point.priv = vsc->fnew(vsc->priv, &pp->point);
- pp->exposed = 1;
- }
+ else
+ vsc->fdestroy(vsc->priv, &pp->point);
}
+ sp->exposed = expose;
}
/*--------------------------------------------------------------------
More information about the varnish-commit
mailing list