Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7858081e
Commit
7858081e
authored
Aug 28, 2008
by
Eric Wong
Committed by
Max Kellermann
Aug 28, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log.c: thread-safety for warning log
I'm really no fan of the warning log, it's too complex for how little it gets used; but fixing it is another problem.
parent
5c26e732
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
log.c
src/log.c
+12
-4
No files found.
src/log.c
View file @
7858081e
...
...
@@ -29,6 +29,7 @@ static unsigned int logLevel = LOG_LEVEL_LOW;
static
int
warningFlushed
;
static
int
stdout_mode
=
1
;
static
char
*
warningBuffer
;
static
pthread_mutex_t
warning_buffer_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
int
out_fd
=
-
1
;
static
int
err_fd
=
-
1
;
static
const
char
*
out_filename
;
...
...
@@ -80,7 +81,10 @@ static void do_log(FILE *fp, const char *fmt, va_list args)
void
flushWarningLog
(
void
)
{
char
*
s
=
warningBuffer
;
char
*
s
;
pthread_mutex_lock
(
&
warning_buffer_lock
);
s
=
warningBuffer
;
DEBUG
(
"flushing warning messages
\n
"
);
...
...
@@ -97,8 +101,8 @@ void flushWarningLog(void)
warningBuffer
=
NULL
;
}
warningFlushed
=
1
;
pthread_mutex_unlock
(
&
warning_buffer_lock
);
DEBUG
(
"done flushing warning messages
\n
"
);
}
...
...
@@ -188,10 +192,14 @@ void WARNING(const char *fmt, ...)
{
va_list
args
;
va_start
(
args
,
fmt
);
if
(
warningFlushed
)
{
pthread_mutex_lock
(
&
warning_buffer_lock
);
if
(
warningFlushed
)
do_log
(
stderr
,
fmt
,
args
);
}
else
else
buffer_warning
(
fmt
,
args
);
pthread_mutex_unlock
(
&
warning_buffer_lock
);
va_end
(
args
);
}
...
...
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