Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
varnishevent
Commits
c4cbd278
Commit
c4cbd278
authored
Jun 02, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the occupancy stats private to MON_, tighten the lock, and
check by assert that they don't go negative
parent
b1b22418
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
11 deletions
+18
-11
data.c
src/data.c
+0
-1
monitor.c
src/monitor.c
+16
-2
test_writer.c
src/test/test_writer.c
+1
-0
varnishevent.c
src/varnishevent.c
+0
-6
varnishevent.h
src/varnishevent.h
+1
-2
No files found.
src/data.c
View file @
c4cbd278
...
...
@@ -192,7 +192,6 @@ DATA_Init(void)
VSTAILQ_INSERT_TAIL
(
&
freetxhead
,
&
txn
[
i
],
freelist
);
}
tx_occ
=
rec_occ
=
chunk_occ
=
tx_occ_hi
=
rec_occ_hi
=
chunk_occ_hi
=
0
;
global_nfree_tx
=
config
.
max_data
;
global_nfree_rec
=
nrecords
;
global_nfree_chunk
=
nchunks
;
...
...
src/monitor.c
View file @
c4cbd278
...
...
@@ -43,6 +43,9 @@ static int run = 0;
static
pthread_t
monitor
;
static
pthread_mutex_t
stats_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
unsigned
tx_occ
=
0
,
rec_occ
=
0
,
chunk_occ
=
0
,
tx_occ_hi
=
0
,
rec_occ_hi
=
0
,
chunk_occ_hi
=
0
;
static
void
log_output
(
void
)
{
...
...
@@ -115,24 +118,35 @@ MON_Start(void)
void
MON_StatsUpdate
(
stats_update_t
update
,
unsigned
nrec
,
unsigned
nchunk
)
{
AZ
(
pthread_mutex_lock
(
&
stats_lock
));
switch
(
update
)
{
case
STATS_WRITTEN
:
AZ
(
pthread_mutex_lock
(
&
stats_lock
));
AN
(
tx_occ
);
assert
(
rec_occ
>=
nrec
);
assert
(
chunk_occ
>=
nchunk
);
tx_occ
--
;
rec_occ
-=
nrec
;
chunk_occ
-=
nchunk
;
AZ
(
pthread_mutex_unlock
(
&
stats_lock
));
break
;
case
STATS_DONE
:
AZ
(
pthread_mutex_lock
(
&
stats_lock
));
tx_occ
++
;
rec_occ
+=
nrec
;
chunk_occ
+=
nchunk
;
AZ
(
pthread_mutex_unlock
(
&
stats_lock
));
if
(
tx_occ
>
tx_occ_hi
)
tx_occ_hi
=
tx_occ
;
if
(
rec_occ
>
rec_occ_hi
)
rec_occ_hi
=
rec_occ
;
if
(
chunk_occ
>
chunk_occ_hi
)
chunk_occ_hi
=
chunk_occ
;
break
;
default:
/* Unreachable */
AN
(
NULL
);
}
AZ
(
pthread_mutex_unlock
(
&
stats_lock
));
}
src/test/test_writer.c
View file @
c4cbd278
...
...
@@ -85,6 +85,7 @@ static char
for
(
int
i
=
0
;
i
<
THRESHOLD
;
i
++
)
{
tx
.
occupied
=
1
;
tx
.
type
=
VSL_t_req
;
MON_StatsUpdate
(
STATS_DONE
,
1
,
1
);
wrt_write
(
&
tx
);
MAZ
(
to
.
tv_sec
);
...
...
src/varnishevent.c
View file @
c4cbd278
...
...
@@ -355,12 +355,6 @@ event(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
tx
->
occupied
=
1
;
seen
++
;
MON_StatsUpdate
(
STATS_DONE
,
nrec
,
total_chunks
);
if
(
tx_occ
>
tx_occ_hi
)
tx_occ_hi
=
tx_occ
;
if
(
rec_occ
>
rec_occ_hi
)
rec_occ_hi
=
rec_occ
;
if
(
chunk_occ
>
chunk_occ_hi
)
chunk_occ_hi
=
chunk_occ
;
submit
(
tx
);
}
...
...
src/varnishevent.h
View file @
c4cbd278
...
...
@@ -119,8 +119,7 @@ typedef VSTAILQ_HEAD(txhead_s, tx_t) txhead_t;
#define OCCUPIED(p) ((p)->occupied == 1)
unsigned
tx_occ
,
rec_occ
,
chunk_occ
,
tx_occ_hi
,
rec_occ_hi
,
chunk_occ_hi
,
global_nfree_tx
,
global_nfree_rec
,
global_nfree_chunk
;
unsigned
global_nfree_tx
,
global_nfree_rec
,
global_nfree_chunk
;
/* Writer (consumer) waits for this condition when the SPSC queue is empty.
Reader (producer) signals the condition after enqueue. */
...
...
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