[master] 3e5f375 Add an enum describing the return values from VSM_StillValid
Martin Blix Grydeland
martin at varnish-cache.org
Wed May 15 14:46:14 CEST 2013
commit 3e5f3757c00a31ece2affb6bf70e32c066ecdee6
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Mon May 13 14:33:45 2013 +0200
Add an enum describing the return values from VSM_StillValid
Use the enum values where VSM_StillValid is used.
diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c
index 89b5812..f45a43a 100644
--- a/bin/varnishstat/varnishstat_curses.c
+++ b/bin/varnishstat/varnishstat_curses.c
@@ -873,7 +873,7 @@ do_curses(struct VSM_data *vd, int delay)
}
VSC_C_mgt = VSC_Mgt(vd, &f_mgt);
VSC_C_main = VSC_Main(vd, &f_main);
- if (VSM_StillValid(vd, &f_iter) != 1)
+ if (VSM_valid != VSM_StillValid(vd, &f_iter))
build_pt_list(vd, &f_iter);
now = VTIM_mono();
diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h
index f6f7f9e..ef1024c 100644
--- a/include/vapi/vsm.h
+++ b/include/vapi/vsm.h
@@ -139,17 +139,23 @@ int VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf);
* vd = "struct VSM_data *"
*/
-int VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf);
+enum VSM_valid_e {
+ VSM_invalid,
+ VSM_valid,
+ VSM_similar,
+};
+
+enum VSM_valid_e VSM_StillValid(const struct VSM_data *vd,
+ struct VSM_fantom *vf);
/*
* This is a cheap syscall-less check to see if the fantom is still
* valid. Further checking with VSM_Abandoned() may be a good
* idea.
*
* Return:
- * 0: fantom is not valid any more.
- * 1: fantom is still the same.
- * 2: a fantom with same dimensions exist in same position,
- * check class/type/ident
+ * VSM_invalid: fantom is not valid any more.
+ * VSM_valid: fantom is still the same.
+ * VSM_similar: a fantom with same dimensions exist in same position.
*/
int VSM_Get(const struct VSM_data *vd, struct VSM_fantom *vf,
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 48fe32d..06c11ce 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -287,7 +287,7 @@ VSC_Get(struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
if (fantom == NULL)
fantom = &f2;
- if (!VSM_StillValid(vd, fantom) &&
+ if (VSM_invalid == VSM_StillValid(vd, fantom) &&
!VSM_Get(vd, fantom, VSC_CLASS, type, ident))
return (NULL);
return ((void*)fantom->b);
@@ -470,7 +470,7 @@ VSC_Iter(struct VSM_data *vd, struct VSM_fantom *fantom, VSC_iter_f *func,
struct vsc_pt *pt;
int i;
- if (1 != VSM_StillValid(vd, &vsc->iter_fantom)) {
+ if (VSM_valid != VSM_StillValid(vd, &vsc->iter_fantom)) {
/* Tell app that list will be nuked */
(void)func(priv, NULL);
vsc_build_vf_list(vd);
diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c
index f4a7738..01808a4 100644
--- a/lib/libvarnishapi/vsl_cursor.c
+++ b/lib/libvarnishapi/vsl_cursor.c
@@ -131,7 +131,7 @@ vslc_vsm_next(void *cursor)
/* Check VSL fantom and abandonment */
if (*(volatile const uint32_t *)c->next.ptr == VSL_ENDMARKER) {
- if (!VSM_StillValid(c->vsm, &c->vf) ||
+ if (VSM_invalid == VSM_StillValid(c->vsm, &c->vf) ||
VSM_Abandoned(c->vsm))
return (-2);
}
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index b40e3d4..60679fd 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -367,7 +367,7 @@ VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf)
/*--------------------------------------------------------------------*/
-int
+enum VSM_valid_e
VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
{
struct VSM_fantom f2;
@@ -375,11 +375,11 @@ VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(vf);
if (!vd->head)
- return (0);
+ return (VSM_invalid);
if (!vd->head->alloc_seq)
- return (0);
+ return (VSM_invalid);
if (vf->priv == vd->head->alloc_seq)
- return (1);
+ return (VSM_valid);
VSM_FOREACH(&f2, vd) {
if (f2.chunk != vf->chunk || f2.b != vf->b || f2.e != vf->e)
continue;
@@ -390,9 +390,9 @@ VSM_StillValid(const struct VSM_data *vd, struct VSM_fantom *vf)
if (strcmp(f2.ident, vf->ident))
continue;
vf->priv = vd->head->alloc_seq;
- return (2);
+ return (VSM_similar);
}
- return (0);
+ return (VSM_invalid);
}
int
More information about the varnish-commit
mailing list