Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
7259fab6
Commit
7259fab6
authored
Mar 12, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lock the VSM alloc/free cals in the child process
parent
958114da
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
9 deletions
+48
-9
cache.h
bin/varnishd/cache.h
+3
-0
cache_main.c
bin/varnishd/cache_main.c
+1
-1
cache_shmlog.c
bin/varnishd/cache_shmlog.c
+27
-1
common.h
bin/varnishd/common.h
+7
-3
mgt.h
bin/varnishd/mgt.h
+5
-0
vsm.c
bin/varnishd/vsm.c
+5
-4
No files found.
bin/varnishd/cache.h
View file @
7259fab6
...
...
@@ -803,6 +803,9 @@ void SES_Charge(struct sess *sp);
/* cache_shmlog.c */
void
VSL_Init
(
void
);
void
*
VSM_Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
);
void
VSM_Free
(
const
void
*
ptr
);
#ifdef VSL_ENDMARKER
void
VSL
(
enum
vsl_tag
tag
,
int
id
,
const
char
*
fmt
,
...);
void
WSLR
(
struct
worker
*
w
,
enum
vsl_tag
tag
,
int
id
,
txt
t
);
...
...
bin/varnishd/cache_main.c
View file @
7259fab6
...
...
@@ -104,7 +104,7 @@ child_main(void)
VSL_Init
();
/* First, LCK needs it. */
LCK_Init
();
/*
Locking, must be first
*/
LCK_Init
();
/*
Second, locking
*/
PAN_Init
();
CLI_Init
();
...
...
bin/varnishd/cache_shmlog.c
View file @
7259fab6
...
...
@@ -40,7 +40,9 @@ SVNID("$Id$")
#include "vmb.h"
#include "vsm.h"
/* These cannot be struct lock, which depends on vsm/vsl working */
static
pthread_mutex_t
vsl_mtx
;
static
pthread_mutex_t
vsm_mtx
;
static
uint32_t
*
vsl_start
;
static
const
uint32_t
*
vsl_end
;
...
...
@@ -275,8 +277,9 @@ VSL_Init(void)
struct
vsm_chunk
*
vsc
;
AZ
(
pthread_mutex_init
(
&
vsl_mtx
,
NULL
));
AZ
(
pthread_mutex_init
(
&
vsm_mtx
,
NULL
));
VSM_Clean
();
VSM_
_
Clean
();
VSM_ITER
(
vsc
)
if
(
!
strcmp
(
vsc
->
class
,
VSL_CLASS
))
...
...
@@ -292,3 +295,26 @@ VSL_Init(void)
memset
(
VSC_main
,
0
,
sizeof
*
VSC_main
);
vsm_head
->
child_pid
=
getpid
();
}
/*--------------------------------------------------------------------*/
void
*
VSM_Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
)
{
void
*
p
;
AZ
(
pthread_mutex_lock
(
&
vsm_mtx
));
p
=
VSM__Alloc
(
size
,
class
,
type
,
ident
);
AZ
(
pthread_mutex_unlock
(
&
vsm_mtx
));
return
(
p
);
}
void
VSM_Free
(
const
void
*
ptr
)
{
AZ
(
pthread_mutex_lock
(
&
vsm_mtx
));
VSM__Free
(
ptr
);
AZ
(
pthread_mutex_unlock
(
&
vsm_mtx
));
}
bin/varnishd/common.h
View file @
7259fab6
...
...
@@ -73,10 +73,14 @@ const void *pick(const struct choice *cp, const char *which, const char *kind);
extern
struct
vsm_head
*
vsm_head
;
extern
const
struct
vsm_chunk
*
vsm_end
;
void
*
VSM_Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
/*
* These three should not be called directly, but only through
* proper vectors in mgt.h/cache.h, hence the __
*/
void
*
VSM__Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
);
void
VSM_Free
(
const
void
*
ptr
);
void
VSM_Clean
(
void
);
void
VSM_
_
Free
(
const
void
*
ptr
);
void
VSM_
_
Clean
(
void
);
/* These classes are opaque to other programs, so we define the here */
#define VSM_CLASS_FREE "Free"
...
...
bin/varnishd/mgt.h
View file @
7259fab6
...
...
@@ -99,3 +99,8 @@ extern unsigned mgt_vcc_err_unref;
fprintf(stderr, fmt "\n", __VA_ARGS__); \
syslog(pri, fmt, __VA_ARGS__); \
} while (0)
#define VSM_Alloc(a, b, c, d) VSM__Alloc(a,b,c,d)
#define VSM_Free(a) VSM__Free(a)
#define VSM_Clean() VSM__Clean()
bin/varnishd/vsm.c
View file @
7259fab6
...
...
@@ -60,6 +60,7 @@ SVNID("$Id$")
#include "vsm.h"
#include "vmb.h"
/* These two come from beyond (mgt_shmem.c actually) */
struct
vsm_head
*
vsm_head
;
const
struct
vsm_chunk
*
vsm_end
;
...
...
@@ -146,7 +147,7 @@ vsm_cleanup(void)
/*--------------------------------------------------------------------*/
void
*
VSM_Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
)
VSM_
_
Alloc
(
unsigned
size
,
const
char
*
class
,
const
char
*
type
,
const
char
*
ident
)
{
struct
vsm_chunk
*
sha
,
*
sha2
;
unsigned
seq
;
...
...
@@ -195,7 +196,7 @@ VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident)
/*--------------------------------------------------------------------*/
void
VSM_Free
(
const
void
*
ptr
)
VSM_
_
Free
(
const
void
*
ptr
)
{
struct
vsm_chunk
*
sha
;
unsigned
seq
;
...
...
@@ -216,7 +217,7 @@ VSM_Free(const void *ptr)
*/
void
VSM_Clean
(
void
)
VSM_
_
Clean
(
void
)
{
struct
vsm_chunk
*
sha
;
unsigned
f
,
seq
;
...
...
@@ -233,7 +234,7 @@ VSM_Clean(void)
continue
;
if
(
strcmp
(
sha
->
class
,
VSM_CLASS_FREE
)
&&
strcmp
(
sha
->
class
,
VSM_CLASS_COOL
))
VSM_Free
(
VSM_PTR
(
sha
));
VSM_
_
Free
(
VSM_PTR
(
sha
));
}
vsm_release
(
seq
);
}
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