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
ea95f53a
Commit
ea95f53a
authored
Dec 16, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
STV_{alloc|free|trim}() are only used from SML.
parent
cb7c4704
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
63 deletions
+60
-63
cache.h
bin/varnishd/cache/cache.h
+0
-4
stevedore.c
bin/varnishd/storage/stevedore.c
+0
-50
storage.h
bin/varnishd/storage/storage.h
+3
-3
storage_simple.c
bin/varnishd/storage/storage_simple.c
+57
-6
No files found.
bin/varnishd/cache/cache.h
View file @
ea95f53a
...
...
@@ -1042,10 +1042,6 @@ void RFC2616_Vary_AE(struct http *hp);
/* stevedore.c */
int
STV_NewObject
(
struct
worker
*
,
struct
objcore
*
,
const
char
*
hint
,
unsigned
len
);
struct
storage
*
STV_alloc
(
const
struct
stevedore
*
,
size_t
size
);
void
STV_trim
(
const
struct
stevedore
*
,
struct
storage
*
,
size_t
size
,
int
move_ok
);
void
STV_free
(
const
struct
stevedore
*
,
struct
storage
*
st
);
void
STV_open
(
void
);
void
STV_close
(
void
);
int
STV_BanInfo
(
enum
baninfo
event
,
const
uint8_t
*
ban
,
unsigned
len
);
...
...
bin/varnishd/storage/stevedore.c
View file @
ea95f53a
...
...
@@ -101,35 +101,6 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint)
return
(
stv
);
}
/*-------------------------------------------------------------------*/
struct
storage
*
STV_alloc
(
const
struct
stevedore
*
stv
,
size_t
size
)
{
struct
storage
*
st
;
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
if
(
size
>
cache_param
->
fetch_maxchunksize
)
size
=
cache_param
->
fetch_maxchunksize
;
assert
(
size
<=
UINT_MAX
);
/* field limit in struct storage */
for
(;;)
{
/* try to allocate from it */
AN
(
stv
->
alloc
);
st
=
stv
->
alloc
(
stv
,
size
);
if
(
st
!=
NULL
)
break
;
if
(
size
<=
cache_param
->
fetch_chunksize
)
break
;
size
>>=
1
;
}
CHECK_OBJ_ORNULL
(
st
,
STORAGE_MAGIC
);
return
(
st
);
}
/*-------------------------------------------------------------------
* Allocate storage for an object, based on the header information.
...
...
@@ -174,27 +145,6 @@ STV_NewObject(struct worker *wrk, struct objcore *oc,
/*-------------------------------------------------------------------*/
void
STV_trim
(
const
struct
stevedore
*
stv
,
struct
storage
*
st
,
size_t
size
,
int
move_ok
)
{
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
if
(
stv
->
trim
)
stv
->
trim
(
st
,
size
,
move_ok
);
}
void
STV_free
(
const
struct
stevedore
*
stv
,
struct
storage
*
st
)
{
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
AN
(
stv
->
free
);
stv
->
free
(
st
);
}
void
STV_open
(
void
)
{
...
...
bin/varnishd/storage/storage.h
View file @
ea95f53a
...
...
@@ -86,9 +86,9 @@ struct stevedore {
unsigned
transient
;
storage_init_f
*
init
;
/* called by mgt process */
storage_open_f
*
open
;
/* called by cache process */
storage_alloc_f
*
alloc
;
/* --//-- */
storage_trim_f
*
trim
;
/* --//-- */
storage_free_f
*
free
;
/* --//-- */
storage_alloc_f
*
alloc
;
/* --//--
only if SML
*/
storage_trim_f
*
trim
;
/* --//--
only if SML
*/
storage_free_f
*
free
;
/* --//--
only if SML
*/
storage_close_f
*
close
;
/* --//-- */
storage_allocobj_f
*
allocobj
;
/* --//-- */
storage_signal_close_f
*
signal_close
;
/* --//-- */
...
...
bin/varnishd/storage/storage_simple.c
View file @
ea95f53a
...
...
@@ -39,6 +39,57 @@
#include "storage/storage.h"
#include "storage/storage_simple.h"
/*-------------------------------------------------------------------*/
static
struct
storage
*
sml_stv_alloc
(
const
struct
stevedore
*
stv
,
size_t
size
)
{
struct
storage
*
st
;
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
if
(
size
>
cache_param
->
fetch_maxchunksize
)
size
=
cache_param
->
fetch_maxchunksize
;
assert
(
size
<=
UINT_MAX
);
/* field limit in struct storage */
for
(;;)
{
/* try to allocate from it */
AN
(
stv
->
alloc
);
st
=
stv
->
alloc
(
stv
,
size
);
if
(
st
!=
NULL
)
break
;
if
(
size
<=
cache_param
->
fetch_chunksize
)
break
;
size
>>=
1
;
}
CHECK_OBJ_ORNULL
(
st
,
STORAGE_MAGIC
);
return
(
st
);
}
static
void
sml_stv_free
(
const
struct
stevedore
*
stv
,
struct
storage
*
st
)
{
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
AN
(
stv
->
free
);
stv
->
free
(
st
);
}
static
void
sml_stv_trim
(
const
struct
stevedore
*
stv
,
struct
storage
*
st
,
size_t
size
,
int
move_ok
)
{
CHECK_OBJ_NOTNULL
(
stv
,
STEVEDORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
if
(
stv
->
trim
)
stv
->
trim
(
st
,
size
,
move_ok
);
}
/*--------------------------------------------------------------------
* This function is called by stevedores ->allocobj() method, which
* very often will be SML_allocobj() below, to convert a slab
...
...
@@ -142,7 +193,7 @@ sml_objfree(struct worker *wrk, struct objcore *oc)
CAST_OBJ_NOTNULL
(
o
,
oc
->
stobj
->
priv
,
OBJECT_MAGIC
);
o
->
magic
=
0
;
STV
_free
(
oc
->
stobj
->
stevedore
,
o
->
objstore
);
sml_stv
_free
(
oc
->
stobj
->
stevedore
,
o
->
objstore
);
memset
(
oc
->
stobj
,
0
,
sizeof
oc
->
stobj
);
...
...
@@ -269,7 +320,7 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size)
for
(
fail
=
0
;
fail
<=
cache_param
->
nuke_limit
;
fail
++
)
{
/* try to allocate from it */
AN
(
stv
->
alloc
);
st
=
STV
_alloc
(
stv
,
size
);
st
=
sml_stv
_alloc
(
stv
,
size
);
if
(
st
!=
NULL
)
break
;
...
...
@@ -372,9 +423,9 @@ sml_trimstore(struct worker *wrk, struct objcore *oc)
return
;
if
(
st
->
len
==
0
)
{
VTAILQ_REMOVE
(
&
o
->
list
,
st
,
list
);
STV
_free
(
stv
,
st
);
sml_stv
_free
(
stv
,
st
);
}
else
if
(
st
->
len
<
st
->
space
)
{
STV
_trim
(
stv
,
st
,
st
->
len
,
1
);
sml_stv
_trim
(
stv
,
st
,
st
->
len
,
1
);
}
}
...
...
@@ -393,13 +444,13 @@ sml_slim(struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
if
(
o
->
esidata
!=
NULL
)
{
STV
_free
(
stv
,
o
->
esidata
);
sml_stv
_free
(
stv
,
o
->
esidata
);
o
->
esidata
=
NULL
;
}
VTAILQ_FOREACH_SAFE
(
st
,
&
o
->
list
,
list
,
stn
)
{
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
VTAILQ_REMOVE
(
&
o
->
list
,
st
,
list
);
STV
_free
(
stv
,
st
);
sml_stv
_free
(
stv
,
st
);
}
}
...
...
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