Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tapir
Manage
Activity
Members
Labels
Plan
Issues
8
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
syslab
tapir
Commits
2af56b43
Commit
2af56b43
authored
8 years ago
by
Naveen Kr. Sharma
Browse files
Options
Downloads
Patches
Plain Diff
Making message print thread safe to prevent output mangling
parent
7e2342d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/message.cc
+10
-0
10 additions, 0 deletions
lib/message.cc
with
10 additions
and
0 deletions
lib/message.cc
+
10
−
0
View file @
2af56b43
...
...
@@ -40,6 +40,8 @@
#include
<unistd.h>
#include
<sys/time.h>
#include
<mutex>
#define BACKTRACE_ON_PANIC 1
#if BACKTRACE_ON_PANIC
#include
<execinfo.h>
...
...
@@ -48,6 +50,8 @@
#define TIMESTAMP_BASE62 0
#define TIMESTAMP_NUMERIC 1
std
::
mutex
mtx
;
void
__attribute__
((
weak
))
Message_VA
(
enum
Message_Type
type
,
const
char
*
fname
,
int
line
,
const
char
*
func
,
...
...
@@ -74,6 +78,9 @@ _Message_VA(enum Message_Type type, FILE *fp,
const
char
*
fname
,
int
line
,
const
char
*
func
,
const
char
*
fmt
,
va_list
args
)
{
// Lock mutex to make sure the output is not mangled.
mtx
.
lock
();
static
int
haveColor
=
-
1
;
struct
msg_desc
{
const
char
*
prefix
;
...
...
@@ -150,6 +157,9 @@ _Message_VA(enum Message_Type type, FILE *fp,
fputs
(
"
\033
[0m"
,
fp
);
fprintf
(
fp
,
"
\n
"
);
fflush
(
fp
);
// Unlock mutex.
mtx
.
unlock
();
}
void
_Panic
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment