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
baf85418
Commit
baf85418
authored
Sep 15, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't needlessly return struct object
parent
35a9e755
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
23 deletions
+19
-23
stevedore.c
bin/varnishd/storage/stevedore.c
+14
-18
storage.h
bin/varnishd/storage/storage.h
+1
-1
storage_persistent.c
bin/varnishd/storage/storage_persistent.c
+4
-4
No files found.
bin/varnishd/storage/stevedore.c
View file @
baf85418
...
...
@@ -218,7 +218,7 @@ STV_MkObject(struct stevedore *stv, struct objcore *oc, void *ptr)
* implement persistent storage can rely on.
*/
struct
object
*
int
stv_default_allocobj
(
struct
stevedore
*
stv
,
struct
objcore
*
oc
,
unsigned
ltot
)
{
struct
object
*
o
;
...
...
@@ -227,16 +227,16 @@ stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
st
=
stv
->
alloc
(
stv
,
ltot
);
if
(
st
==
NULL
)
return
(
NULL
);
return
(
0
);
if
(
st
->
space
<
ltot
)
{
stv
->
free
(
st
);
return
(
NULL
);
return
(
0
);
}
o
=
STV_MkObject
(
stv
,
oc
,
st
->
ptr
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
st
->
len
=
sizeof
(
*
o
);
o
->
objstore
=
st
;
return
(
o
);
return
(
1
);
}
/*-------------------------------------------------------------------
...
...
@@ -248,11 +248,10 @@ stv_default_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
int
STV_NewObject
(
struct
busyobj
*
bo
,
const
char
*
hint
,
unsigned
wsl
)
{
struct
object
*
o
;
struct
objcore
*
oc
;
struct
stevedore
*
stv
,
*
stv0
;
unsigned
ltot
;
int
i
;
int
i
,
j
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
oc
=
bo
->
fetch_objcore
;
...
...
@@ -260,36 +259,33 @@ STV_NewObject(struct busyobj *bo, const char *hint, unsigned wsl)
assert
(
wsl
>
0
);
wsl
=
PRNDUP
(
wsl
);
ltot
=
sizeof
*
o
+
wsl
;
ltot
=
sizeof
(
struct
object
)
+
wsl
;
stv
=
stv0
=
stv_pick_stevedore
(
bo
->
vsl
,
&
hint
);
AN
(
stv
->
allocobj
);
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
if
(
o
==
NULL
&&
hint
==
NULL
)
{
j
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
if
(
j
==
0
&&
hint
==
NULL
)
{
do
{
stv
=
stv_pick_stevedore
(
bo
->
vsl
,
&
hint
);
AN
(
stv
->
allocobj
);
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
}
while
(
o
==
NULL
&&
stv
!=
stv0
);
j
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
}
while
(
j
==
0
&&
stv
!=
stv0
);
}
if
(
o
==
NULL
)
{
if
(
j
==
0
)
{
/* no luck; try to free some space and keep trying */
for
(
i
=
0
;
o
==
NULL
&&
i
<
cache_param
->
nuke_limit
;
i
++
)
{
for
(
i
=
0
;
j
==
0
&&
i
<
cache_param
->
nuke_limit
;
i
++
)
{
if
(
EXP_NukeOne
(
bo
->
vsl
,
bo
->
stats
,
stv
->
lru
)
==
-
1
)
break
;
o
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
j
=
stv
->
allocobj
(
stv
,
oc
,
ltot
);
}
}
if
(
o
==
NULL
)
if
(
j
==
0
)
return
(
0
);
bo
->
stats
->
n_object
++
;
VSLb
(
bo
->
vsl
,
SLT_Storage
,
"%s %s"
,
oc
->
stobj
->
stevedore
->
name
,
oc
->
stobj
->
stevedore
->
ident
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
CHECK_OBJ_NOTNULL
(
o
->
objstore
,
STORAGE_MAGIC
);
AN
(
stv
->
methods
);
return
(
1
);
}
...
...
bin/varnishd/storage/storage.h
View file @
baf85418
...
...
@@ -61,7 +61,7 @@ typedef void storage_open_f(const struct stevedore *);
typedef
struct
storage
*
storage_alloc_f
(
struct
stevedore
*
,
size_t
size
);
typedef
void
storage_trim_f
(
struct
storage
*
,
size_t
size
,
int
move_ok
);
typedef
void
storage_free_f
(
struct
storage
*
);
typedef
struct
object
*
storage_allocobj_f
(
struct
stevedore
*
,
struct
objcore
*
,
typedef
int
storage_allocobj_f
(
struct
stevedore
*
,
struct
objcore
*
,
unsigned
ltot
);
typedef
void
storage_close_f
(
const
struct
stevedore
*
);
typedef
void
storage_signal_close_f
(
const
struct
stevedore
*
);
...
...
bin/varnishd/storage/storage_persistent.c
View file @
baf85418
...
...
@@ -504,7 +504,7 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
* Allocate an object
*/
static
struct
object
*
static
int
smp_allocobj
(
struct
stevedore
*
stv
,
struct
objcore
*
oc
,
unsigned
ltot
)
{
struct
object
*
o
;
...
...
@@ -519,13 +519,13 @@ smp_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
/* Don't entertain already dead objects */
if
((
oc
->
exp
.
ttl
+
oc
->
exp
.
grace
+
oc
->
exp
.
keep
)
<=
0
.)
return
(
NULL
);
return
(
0
);
ltot
=
IRNUP
(
sc
,
ltot
);
st
=
smp_allocx
(
stv
,
ltot
,
ltot
,
&
so
,
&
objidx
,
&
sg
);
if
(
st
==
NULL
)
return
(
NULL
);
return
(
0
);
assert
(
st
->
space
>=
ltot
);
...
...
@@ -550,7 +550,7 @@ smp_allocobj(struct stevedore *stv, struct objcore *oc, unsigned ltot)
smp_init_oc
(
oc
,
sg
,
objidx
);
Lck_Unlock
(
&
sc
->
mtx
);
return
(
o
);
return
(
1
);
}
/*--------------------------------------------------------------------
...
...
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