[master] 4b52825 Move the storage_simples "getobj" helper method from oc to stv.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Feb 5 23:24:41 CET 2016
commit 4b528257611c6568cc70d85c58805d12fb6b65d5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Feb 5 22:17:49 2016 +0000
Move the storage_simples "getobj" helper method from oc to stv.
diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h
index 830efce..41e3ae5 100644
--- a/bin/varnishd/cache/cache_obj.h
+++ b/bin/varnishd/cache/cache_obj.h
@@ -34,7 +34,6 @@ typedef void objupdatemeta_f(struct worker *, struct objcore *);
typedef void objfree_f(struct worker *, struct objcore *);
/* This method is only used by SML (...to get to persistent) */
-typedef struct object *sml_getobj_f(struct worker *, struct objcore *);
typedef int objiterator_f(struct worker *, struct objcore *,
void *priv, objiterate_f *func);
@@ -54,8 +53,6 @@ struct obj_methods {
objfree_f *objfree;
objupdatemeta_f *objupdatemeta;
- sml_getobj_f *sml_getobj;
-
objiterator_f *objiterator;
objgetspace_f *objgetspace;
objextend_f *objextend;
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 6696b01..f492de2 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -59,8 +59,6 @@ struct storage {
typedef void storage_init_f(struct stevedore *, int ac, char * const *av);
typedef void storage_open_f(struct stevedore *);
-typedef struct storage *storage_alloc_f(const struct stevedore *, size_t size);
-typedef void storage_free_f(struct storage *);
typedef int storage_allocobj_f(struct worker *, const struct stevedore *,
struct objcore *, unsigned ltot, int really);
typedef void storage_close_f(const struct stevedore *);
@@ -70,6 +68,10 @@ typedef int storage_baninfo_f(const struct stevedore *, enum baninfo event,
typedef void storage_banexport_f(const struct stevedore *, const uint8_t *bans,
unsigned len);
+typedef struct object *storage_getobj_f(struct worker *, struct objcore *);
+typedef struct storage *storage_alloc_f(const struct stevedore *, size_t size);
+typedef void storage_free_f(struct storage *);
+
/* Prototypes for VCL variable responders */
#define VRTSTVTYPE(ct) typedef ct storage_var_##ct(const struct stevedore *);
#include "tbl/vrt_stv_var.h"
@@ -86,6 +88,7 @@ struct stevedore {
storage_open_f *open; /* called by cache process */
storage_alloc_f *sml_alloc; /* --//-- only if SML */
storage_free_f *sml_free; /* --//-- only if SML */
+ storage_getobj_f *sml_getobj; /* --//-- only if SML */
storage_close_f *close; /* --//-- */
storage_allocobj_f *allocobj; /* --//-- */
storage_signal_close_f *signal_close; /* --//-- */
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 20a4aec..ce67b35 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -593,13 +593,15 @@ const struct stevedore smp_stevedore = {
.init = smp_mgt_init,
.open = smp_open,
.close = smp_close,
- .sml_alloc = smp_alloc,
.allocobj = smp_allocobj,
- .sml_free = NULL,
.signal_close = smp_signal_close,
.baninfo = smp_baninfo,
.banexport = smp_banexport,
.methods = &smp_oc_realmethods,
+
+ .sml_alloc = smp_alloc,
+ .sml_free = NULL,
+ .sml_getobj = smp_sml_getobj,
};
/*--------------------------------------------------------------------
@@ -686,7 +688,6 @@ SMP_Init(void)
lck_smp = Lck_CreateClass("smp");
CLI_AddFuncs(debug_cmds);
smp_oc_realmethods = SML_methods;
- smp_oc_realmethods.sml_getobj = smp_oc_methods.sml_getobj;
smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta;
smp_oc_realmethods.objfree = smp_oc_methods.objfree;
smp_oc_realmethods.objtouch = NULL;
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index 4a28ba6..410bc48 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -308,6 +308,7 @@ void smp_close_seg(struct smp_sc *sc, struct smp_seg *sg);
void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx);
void smp_save_segs(struct smp_sc *sc);
extern const struct obj_methods smp_oc_methods;
+storage_getobj_f smp_sml_getobj;
/* storage_persistent_subr.c */
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 74b74fe..87d81e8 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -388,8 +388,8 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg,
* objcore methods for persistent objects
*/
-static struct object *
-smp_oc_sml_getobj(struct worker *wrk, struct objcore *oc)
+struct object *
+smp_sml_getobj(struct worker *wrk, struct objcore *oc)
{
struct object *o;
struct smp_seg *sg;
@@ -402,9 +402,6 @@ smp_oc_sml_getobj(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(oc->stobj->stevedore);
- /* Some calls are direct, but they should match anyway */
- assert(oc->stobj->stevedore->methods->sml_getobj == smp_oc_sml_getobj);
-
CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC);
so = smp_find_so(sg, oc->stobj->priv2);
@@ -513,7 +510,6 @@ smp_oc_objfree(struct worker *wrk, struct objcore *oc)
}
const struct obj_methods smp_oc_methods = {
- .sml_getobj = smp_oc_sml_getobj,
.objupdatemeta = smp_oc_objupdatemeta,
.objfree = smp_oc_objfree,
};
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 42112e7..40e3b31 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -156,14 +156,15 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
static struct object *
sml_getobj(struct worker *wrk, struct objcore *oc)
{
- const struct obj_methods *m;
+ const struct stevedore *stv;
struct object *o;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- m = oc->stobj->stevedore->methods;
- if (m->sml_getobj != NULL)
- return (m->sml_getobj(wrk, oc));
+ stv = oc->stobj->stevedore;
+ CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
+ if (stv->sml_getobj != NULL)
+ return (stv->sml_getobj(wrk, oc));
if (oc->stobj->priv == NULL)
return (NULL);
CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
More information about the varnish-commit
mailing list