Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent3
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
varnishevent3
Commits
4165081e
Commit
4165081e
authored
Oct 07, 2013
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
varnishevent: clean up threading and writer.c
parent
e2eb137f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
29 deletions
+21
-29
data.c
bin/varnishevent/data.c
+1
-2
monitor.c
bin/varnishevent/monitor.c
+1
-2
varnishevent.c
bin/varnishevent/varnishevent.c
+9
-6
varnishevent.h
bin/varnishevent/varnishevent.h
+0
-4
writer.c
bin/varnishevent/writer.c
+10
-15
No files found.
bin/varnishevent/data.c
View file @
4165081e
...
...
@@ -41,7 +41,7 @@
static
const
char
*
statename
[
3
]
=
{
"EMPTY"
,
"OPEN"
,
"DONE"
};
static
pthread_mutex_t
freelist_lock
;
static
pthread_mutex_t
freelist_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
char
*
bufptr
;
static
int
ntags
;
...
...
@@ -164,7 +164,6 @@ DATA_Init(void)
assert
(
bufidx
==
nrecords
);
AZ
(
pthread_mutex_init
(
&
freelist_lock
,
&
attr_lock
));
data_open
=
data_done
=
data_occ_hi
=
0
;
global_nfree
=
config
.
max_data
;
...
...
bin/varnishevent/monitor.c
View file @
4165081e
...
...
@@ -40,7 +40,7 @@
static
int
run
;
static
pthread_t
monitor
;
static
pthread_mutex_t
stats_lock
;
static
pthread_mutex_t
stats_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
void
log_output
(
void
)
...
...
@@ -103,7 +103,6 @@ MON_Shutdown(void)
void
MON_Start
(
void
)
{
AZ
(
pthread_mutex_init
(
&
stats_lock
,
&
attr_lock
));
AZ
(
pthread_create
(
&
monitor
,
NULL
,
monitor_main
,
NULL
));
}
...
...
bin/varnishevent/varnishevent.c
View file @
4165081e
...
...
@@ -718,12 +718,6 @@ main(int argc, char *argv[])
if
(
!
EMPTY
(
config
.
zformat
))
z_flag
=
1
;
AZ
(
pthread_mutexattr_init
(
&
attr_lock
));
AZ
(
pthread_condattr_init
(
&
attr_cond
));
AZ
(
pthread_mutexattr_setpshared
(
&
attr_lock
,
PTHREAD_PROCESS_PRIVATE
));
AZ
(
pthread_condattr_setpshared
(
&
attr_cond
,
PTHREAD_PROCESS_PRIVATE
));
if
((
errnum
=
DATA_Init
())
!=
0
)
{
LOG_Log
(
LOG_ALERT
,
"Cannot init data table: %s
\n
"
,
strerror
(
errnum
));
...
...
@@ -741,6 +735,11 @@ main(int argc, char *argv[])
fd_tbl
[
k
].
state
=
FD_EMPTY
;
}
AZ
(
pthread_cond_init
(
&
data_ready_cond
,
NULL
));
AZ
(
pthread_mutex_init
(
&
data_ready_lock
,
NULL
));
AZ
(
pthread_cond_init
(
&
spscq_ready_cond
,
NULL
));
AZ
(
pthread_mutex_init
(
&
spscq_ready_lock
,
NULL
));
if
(
config
.
monitor_interval
>
0
)
MON_Start
();
else
...
...
@@ -788,6 +787,10 @@ main(int argc, char *argv[])
SPSCQ_Shutdown
();
MON_Shutdown
();
FMT_Shutdown
();
AZ
(
pthread_cond_destroy
(
&
data_ready_cond
));
AZ
(
pthread_mutex_destroy
(
&
data_ready_lock
));
AZ
(
pthread_cond_destroy
(
&
spscq_ready_cond
));
AZ
(
pthread_mutex_destroy
(
&
spscq_ready_lock
));
LOG_Log0
(
LOG_INFO
,
"Exiting"
);
LOG_Close
();
...
...
bin/varnishevent/varnishevent.h
View file @
4165081e
...
...
@@ -123,10 +123,6 @@ pthread_mutex_t data_ready_lock;
pthread_cond_t
spscq_ready_cond
;
pthread_mutex_t
spscq_ready_lock
;
/* Used for all mutexes and condition variables to set them PROCESS_PRIVATE */
pthread_mutexattr_t
attr_lock
;
pthread_condattr_t
attr_cond
;
struct
config
{
char
pid_file
[
BUFSIZ
];
...
...
bin/varnishevent/writer.c
View file @
4165081e
...
...
@@ -73,7 +73,7 @@ static struct vsb *os;
static
FILE
*
fo
;
static
char
*
obuf
=
NULL
;
static
pthread_mutex_t
reopen_lock
;
static
pthread_mutex_t
reopen_lock
=
PTHREAD_MUTEX_INITIALIZER
;
/* stats */
static
unsigned
deqs
=
0
;
...
...
@@ -90,7 +90,7 @@ typedef struct writer_data_s {
static
writer_data_t
wrt_data
;
static
unsigned
run
,
cleaned
=
0
,
reopen
=
0
;
static
unsigned
run
,
reopen
=
0
;
static
int
open_log
(
void
)
...
...
@@ -246,23 +246,14 @@ static void
pthread_exit
((
void
*
)
wrt
);
}
static
void
wrt_cleanup
(
void
)
{
if
(
cleaned
)
return
;
cleaned
=
1
;
}
int
WRT_Init
(
void
)
{
int
err
;
if
((
err
=
open_log
())
!=
0
)
return
err
;
AZ
(
pthread_mutex_init
(
&
reopen_lock
,
&
attr_lock
));
wrt_data
.
magic
=
WRITER_DATA_MAGIC
;
wrt_data
.
state
=
WRT_NOTSTARTED
;
...
...
@@ -317,7 +308,7 @@ WRT_Halt(void)
AZ
(
pthread_mutex_lock
(
&
spscq_ready_lock
));
run
=
0
;
AZ
(
pthread_cond_
broadcast
(
&
spscq_ready_cond
));
AZ
(
pthread_cond_
signal
(
&
spscq_ready_cond
));
AZ
(
pthread_mutex_unlock
(
&
spscq_ready_lock
));
AZ
(
pthread_join
(
writer
,
(
void
**
)
&
wrt
));
...
...
@@ -329,6 +320,10 @@ WRT_Halt(void)
void
WRT_Shutdown
(
void
)
{
/* XXX: error if run=1? */
wrt_cleanup
();
/* WRT_Halt() must always be called first */
AZ
(
run
);
fclose
(
fo
);
free
(
obuf
);
VSB_delete
(
os
);
AZ
(
pthread_mutex_destroy
(
&
reopen_lock
));
}
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