Commit 15aad353 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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.
parent e2944814
......@@ -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 \
......
......@@ -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,
};
/*--------------------------------------------------------------------
*/
......
/*-
* Copyright (c) 2007-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@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,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment