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
d175906e
Commit
d175906e
authored
Jan 21, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A minor code-move, in anticipation of things yet to come.
parent
b5d07794
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
15 deletions
+38
-15
stevedore.c
bin/varnishd/storage/stevedore.c
+38
-15
No files found.
bin/varnishd/storage/stevedore.c
View file @
d175906e
...
...
@@ -159,11 +159,42 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint)
/*-------------------------------------------------------------------*/
static
struct
storage
*
stv_alloc
(
struct
busyobj
*
bo
,
size_t
size
)
stv_alloc
(
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
;
}
if
(
st
!=
NULL
)
CHECK_OBJ_NOTNULL
(
st
,
STORAGE_MAGIC
);
return
(
st
);
}
/*-------------------------------------------------------------------*/
static
struct
storage
*
stv_alloc_obj
(
struct
busyobj
*
bo
,
size_t
size
)
{
struct
storage
*
st
=
NULL
;
struct
stevedore
*
stv
;
unsigned
fail
=
0
;
unsigned
fail
;
struct
object
*
obj
;
/*
...
...
@@ -181,24 +212,16 @@ stv_alloc(struct busyobj *bo, size_t size)
assert
(
size
<=
UINT_MAX
);
/* field limit in struct storage */
for
(
;;
)
{
for
(
fail
=
0
;
fail
<=
cache_param
->
nuke_limit
;
fail
++
)
{
/* try to allocate from it */
AN
(
stv
->
alloc
);
st
=
stv
->
alloc
(
stv
,
size
);
st
=
stv
_
alloc
(
stv
,
size
);
if
(
st
!=
NULL
)
break
;
if
(
size
>
cache_param
->
fetch_chunksize
)
{
size
>>=
1
;
continue
;
}
/* no luck; try to free some space and keep trying */
if
(
EXP_NukeOne
(
bo
,
stv
->
lru
)
==
-
1
)
break
;
/* Enough is enough: try another if we have one */
if
(
++
fail
>=
cache_param
->
nuke_limit
)
if
(
fail
<
cache_param
->
nuke_limit
&&
EXP_NukeOne
(
bo
,
stv
->
lru
)
==
-
1
)
break
;
}
if
(
st
!=
NULL
)
...
...
@@ -390,7 +413,7 @@ struct storage *
STV_alloc
(
struct
busyobj
*
bo
,
size_t
size
)
{
return
(
stv_alloc
(
bo
,
size
));
return
(
stv_alloc
_obj
(
bo
,
size
));
}
void
...
...
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