Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
52f4ccfc
Commit
52f4ccfc
authored
Dec 15, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the objcore methods into their own .h file.
This saves a ugly ifdef for mgt code in storage.h
parent
2c76f5b2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
66 deletions
+94
-66
Makefile.am
bin/varnishd/Makefile.am
+1
-0
cache_obj.c
bin/varnishd/cache/cache_obj.c
+13
-12
cache_obj.h
bin/varnishd/cache/cache_obj.h
+68
-0
storage.h
bin/varnishd/storage/storage.h
+2
-48
storage_persistent.c
bin/varnishd/storage/storage_persistent.c
+2
-1
storage_persistent.h
bin/varnishd/storage/storage_persistent.h
+1
-1
storage_persistent_silo.c
bin/varnishd/storage/storage_persistent_silo.c
+2
-1
storage_simple.c
bin/varnishd/storage/storage_simple.c
+3
-2
storage_simple.h
bin/varnishd/storage/storage_simple.h
+1
-1
storage_umem.c
bin/varnishd/storage/storage_umem.c
+1
-0
No files found.
bin/varnishd/Makefile.am
View file @
52f4ccfc
...
...
@@ -104,6 +104,7 @@ noinst_HEADERS = \
builtin_vcl.h
\
cache/cache_ban.h
\
cache/cache_esi.h
\
cache/cache_obj.h
\
cache/cache_pool.h
\
cache/cache_priv.h
\
common/heritage.h
\
...
...
bin/varnishd/cache/cache_obj.c
View file @
52f4ccfc
...
...
@@ -43,11 +43,12 @@
#include <stdlib.h>
#include "cache.h"
#include "cache_obj.h"
#include "vend.h"
#include "storage/storage.h"
#include "hash/hash_slinger.h"
static
const
struct
store
obj_methods
*
static
const
struct
obj_methods
*
obj_getmethods
(
const
struct
objcore
*
oc
)
{
...
...
@@ -66,7 +67,7 @@ int
ObjIterate
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
void
*
priv
,
objiterate_f
*
func
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
AN
(
func
);
...
...
@@ -86,7 +87,7 @@ ObjIterate(struct worker *wrk, struct objcore *oc,
int
ObjGetSpace
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
ssize_t
*
sz
,
uint8_t
**
ptr
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
AN
(
sz
);
...
...
@@ -107,7 +108,7 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr)
void
ObjExtend
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
ssize_t
l
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
assert
(
l
>
0
);
...
...
@@ -125,7 +126,7 @@ ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l)
uint64_t
ObjGetLen
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -143,7 +144,7 @@ ObjGetLen(struct worker *wrk, struct objcore *oc)
void
ObjTrimStore
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -162,7 +163,7 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
void
ObjSlim
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -175,7 +176,7 @@ ObjSlim(struct worker *wrk, struct objcore *oc)
void
ObjUpdateMeta
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
m
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
m
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -188,7 +189,7 @@ ObjUpdateMeta(struct worker *wrk, struct objcore *oc)
void
ObjFreeObj
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
m
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
m
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -202,7 +203,7 @@ ObjFreeObj(struct worker *wrk, struct objcore *oc)
struct
lru
*
ObjGetLRU
(
const
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
m
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
m
=
obj_getmethods
(
oc
);
AN
(
m
->
objgetlru
);
return
(
m
->
objgetlru
(
oc
));
...
...
@@ -218,7 +219,7 @@ void *
ObjGetattr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
enum
obj_attr
attr
,
ssize_t
*
len
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -237,7 +238,7 @@ void *
ObjSetattr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
)
{
const
struct
store
obj_methods
*
om
=
obj_getmethods
(
oc
);
const
struct
obj_methods
*
om
=
obj_getmethods
(
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
bin/varnishd/cache/cache_obj.h
0 → 100644
View file @
52f4ccfc
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 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.
*
*/
/* Methods on objcore ------------------------------------------------*/
typedef
void
objupdatemeta_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
objfree_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
struct
lru
*
objgetlru_f
(
const
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
);
typedef
int
objgetspace_f
(
struct
worker
*
,
struct
objcore
*
,
ssize_t
*
sz
,
uint8_t
**
ptr
);
typedef
void
objextend_f
(
struct
worker
*
,
struct
objcore
*
,
ssize_t
l
);
typedef
void
objtrimstore_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
objslim_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
*
objgetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
*
len
);
typedef
void
*
objsetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
);
typedef
uint64_t
objgetlen_f
(
struct
worker
*
,
struct
objcore
*
);
struct
obj_methods
{
objfree_f
*
objfree
;
objgetlru_f
*
objgetlru
;
objupdatemeta_f
*
objupdatemeta
;
sml_getobj_f
*
sml_getobj
;
objiterator_f
*
objiterator
;
objgetspace_f
*
objgetspace
;
objextend_f
*
objextend
;
objgetlen_f
*
objgetlen
;
objtrimstore_f
*
objtrimstore
;
objslim_f
*
objslim
;
objgetattr_f
*
objgetattr
;
objsetattr_f
*
objsetattr
;
};
bin/varnishd/storage/storage.h
View file @
52f4ccfc
...
...
@@ -39,6 +39,7 @@ struct worker;
struct
lru
;
struct
vsl_log
;
struct
vfp_ctx
;
struct
obj_methods
;
/* Storage -----------------------------------------------------------*/
...
...
@@ -55,53 +56,6 @@ struct storage {
unsigned
space
;
};
/* Methods on objcore ------------------------------------------------*/
#ifdef VARNISH_CACHE_CHILD
typedef
void
objupdatemeta_f
(
struct
worker
*
,
struct
objcore
*
oc
);
typedef
void
objfree_f
(
struct
worker
*
,
struct
objcore
*
oc
);
typedef
struct
lru
*
objgetlru_f
(
const
struct
objcore
*
oc
);
/* This method is only used by SML (...to get to persistent) */
typedef
struct
object
*
sml_getobj_f
(
struct
worker
*
,
struct
objcore
*
oc
);
typedef
int
objiterator_f
(
struct
worker
*
,
struct
objcore
*
oc
,
void
*
priv
,
objiterate_f
*
func
);
typedef
int
objgetspace_f
(
struct
worker
*
,
struct
objcore
*
,
ssize_t
*
sz
,
uint8_t
**
ptr
);
typedef
void
objextend_f
(
struct
worker
*
,
struct
objcore
*
,
ssize_t
l
);
typedef
void
objtrimstore_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
objslim_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
*
objgetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
*
len
);
typedef
void
*
objsetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
);
typedef
uint64_t
objgetlen_f
(
struct
worker
*
,
struct
objcore
*
);
struct
storeobj_methods
{
objfree_f
*
objfree
;
objgetlru_f
*
objgetlru
;
objupdatemeta_f
*
objupdatemeta
;
sml_getobj_f
*
sml_getobj
;
objiterator_f
*
objiterator
;
objgetspace_f
*
objgetspace
;
objextend_f
*
objextend
;
objgetlen_f
*
objgetlen
;
objtrimstore_f
*
objtrimstore
;
objslim_f
*
objslim
;
objgetattr_f
*
objgetattr
;
objsetattr_f
*
objsetattr
;
};
#else
struct
storeobj_methods
;
#endif
/* Prototypes --------------------------------------------------------*/
typedef
void
storage_init_f
(
struct
stevedore
*
,
int
ac
,
char
*
const
*
av
);
...
...
@@ -141,7 +95,7 @@ struct stevedore {
storage_baninfo_f
*
baninfo
;
/* --//-- */
storage_banexport_f
*
banexport
;
/* --//-- */
const
struct
store
obj_methods
const
struct
obj_methods
*
methods
;
struct
lru
*
lru
;
...
...
bin/varnishd/storage/storage_persistent.c
View file @
52f4ccfc
...
...
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include "cache/cache.h"
#include "cache/cache_obj.h"
#include "storage/storage.h"
#include "storage/storage_simple.h"
...
...
@@ -54,7 +55,7 @@
#include "storage/storage_persistent.h"
static
struct
store
obj_methods
smp_oc_realmethods
;
static
struct
obj_methods
smp_oc_realmethods
;
/*--------------------------------------------------------------------*/
...
...
bin/varnishd/storage/storage_persistent.h
View file @
52f4ccfc
...
...
@@ -307,7 +307,7 @@ void smp_new_seg(struct smp_sc *sc);
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
store
obj_methods
smp_oc_methods
;
extern
const
struct
obj_methods
smp_oc_methods
;
/* storage_persistent_subr.c */
...
...
bin/varnishd/storage/storage_persistent_silo.c
View file @
52f4ccfc
...
...
@@ -39,6 +39,7 @@
#include <stdlib.h>
#include "cache/cache.h"
#include "cache/cache_obj.h"
#include "storage/storage.h"
#include "storage/storage_simple.h"
...
...
@@ -526,7 +527,7 @@ smp_oc_objgetlru(const struct objcore *oc)
return
(
sg
->
lru
);
}
const
struct
store
obj_methods
smp_oc_methods
=
{
const
struct
obj_methods
smp_oc_methods
=
{
.
sml_getobj
=
smp_oc_sml_getobj
,
.
objupdatemeta
=
smp_oc_objupdatemeta
,
.
objfree
=
smp_oc_objfree
,
...
...
bin/varnishd/storage/storage_simple.c
View file @
52f4ccfc
...
...
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include "cache/cache.h"
#include "cache/cache_obj.h"
#include "hash/hash_slinger.h"
#include "storage/storage.h"
...
...
@@ -103,7 +104,7 @@ SML_allocobj(const struct stevedore *stv, struct objcore *oc,
static
struct
object
*
getobj
(
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
const
struct
store
obj_methods
*
m
;
const
struct
obj_methods
*
m
;
struct
object
*
o
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -494,7 +495,7 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
}
const
struct
store
obj_methods
SML_methods
=
{
const
struct
obj_methods
SML_methods
=
{
.
objfree
=
sml_objfree
,
.
objgetlru
=
sml_objgetlru
,
.
objiterator
=
sml_iterator
,
...
...
bin/varnishd/storage/storage_simple.h
View file @
52f4ccfc
...
...
@@ -53,7 +53,7 @@ struct object {
struct
storage
*
esidata
;
};
extern
const
struct
store
obj_methods
SML_methods
;
extern
const
struct
obj_methods
SML_methods
;
struct
object
*
SML_MkObject
(
const
struct
stevedore
*
,
struct
objcore
*
,
void
*
ptr
);
...
...
bin/varnishd/storage/storage_umem.c
View file @
52f4ccfc
...
...
@@ -40,6 +40,7 @@
#include <umem.h>
#include "cache/cache.h"
#include "cache/cache_obj.h"
#include "storage/storage.h"
#include "storage/storage_simple.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment