[master] 15aad35 Move the default objcore->methods into their own file.

Poul-Henning Kamp phk at FreeBSD.org
Mon Dec 14 23:36:58 CET 2015


commit 15aad353d94fae4e3108ab2acc335c95f7bd9c0f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 14 21:29:19 2015 +0000

    Move the default objcore->methods into their own file.
    
    These are the methods used by "simple" stevedores, more advanced
    stevedores can bring their own set.

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 0648822..99e7fb4 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -91,6 +91,7 @@ varnishd_SOURCES = \
 	storage/mgt_storage_persistent.c \
 	storage/storage_persistent_silo.c \
 	storage/storage_persistent_subr.c \
+	storage/storage_simple.c \
 	storage/storage_umem.c \
 	waiter/mgt_waiter.c \
 	waiter/cache_waiter.c \
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 77e54a3..6c0ad0b 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -44,58 +44,6 @@
 
 static const struct stevedore * volatile stv_next;
 
-/*---------------------------------------------------------------------
- * Default objcore methods
- */
-
-static struct object * __match_proto__(getobj_f)
-default_oc_getobj(struct worker *wrk, struct objcore *oc)
-{
-	struct object *o;
-
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	if (oc->stobj->priv == NULL)
-		return (NULL);
-	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
-	return (o);
-}
-
-static void __match_proto__(freeobj_f)
-default_oc_freeobj(struct worker *wrk, struct objcore *oc)
-{
-	struct object *o;
-
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	CHECK_OBJ_NOTNULL(oc->stobj, STOREOBJ_MAGIC);
-	ObjSlim(wrk, oc);
-	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
-	o->magic = 0;
-
-	STV_free(oc->stobj->stevedore, o->objstore);
-
-	memset(oc->stobj, 0, sizeof oc->stobj);
-
-	wrk->stats->n_object--;
-}
-
-static struct lru * __match_proto__(getlru_f)
-default_oc_getlru(const struct objcore *oc)
-{
-	const struct stevedore *stv;
-
-	stv = oc->stobj->stevedore;
-	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
-	return (stv->lru);
-}
-
-const struct storeobj_methods default_oc_methods = {
-	.getobj = default_oc_getobj,
-	.freeobj = default_oc_freeobj,
-	.getlru = default_oc_getlru,
-};
-
 /*--------------------------------------------------------------------
  */
 
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
new file mode 100644
index 0000000..141b413
--- /dev/null
+++ b/bin/varnishd/storage/storage_simple.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2007-2015 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cache/cache.h"
+
+#include "storage/storage.h"
+
+/*---------------------------------------------------------------------
+ */
+
+static struct object * __match_proto__(getobj_f)
+default_oc_getobj(struct worker *wrk, struct objcore *oc)
+{
+	struct object *o;
+
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	if (oc->stobj->priv == NULL)
+		return (NULL);
+	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
+	return (o);
+}
+
+static void __match_proto__(freeobj_f)
+default_oc_freeobj(struct worker *wrk, struct objcore *oc)
+{
+	struct object *o;
+
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(oc->stobj, STOREOBJ_MAGIC);
+	ObjSlim(wrk, oc);
+	CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC);
+	o->magic = 0;
+
+	STV_free(oc->stobj->stevedore, o->objstore);
+
+	memset(oc->stobj, 0, sizeof oc->stobj);
+
+	wrk->stats->n_object--;
+}
+
+static struct lru * __match_proto__(getlru_f)
+default_oc_getlru(const struct objcore *oc)
+{
+	const struct stevedore *stv;
+
+	stv = oc->stobj->stevedore;
+	CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC);
+	return (stv->lru);
+}
+
+const struct storeobj_methods default_oc_methods = {
+	.getobj = default_oc_getobj,
+	.freeobj = default_oc_freeobj,
+	.getlru = default_oc_getlru,
+};



More information about the varnish-commit mailing list