Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Illuna-Minetest
illuna-minetest
Commits
de0cdbc0
Commit
de0cdbc0
authored
11 years ago
by
sapier
Browse files
Options
Downloads
Patches
Plain Diff
Fix log threadname lookup handling not beeing threadsafe
parent
e605d702
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/jthread/pthread/jmutex.cpp
+5
-9
5 additions, 9 deletions
src/jthread/pthread/jmutex.cpp
src/jthread/win32/jmutex.cpp
+8
-11
8 additions, 11 deletions
src/jthread/win32/jmutex.cpp
src/log.cpp
+6
-1
6 additions, 1 deletion
src/log.cpp
with
19 additions
and
21 deletions
src/jthread/pthread/jmutex.cpp
+
5
−
9
View file @
de0cdbc0
...
...
@@ -29,7 +29,8 @@
JMutex
::
JMutex
()
{
initialized
=
false
;
pthread_mutex_init
(
&
mutex
,
NULL
);
initialized
=
true
;
}
JMutex
::~
JMutex
()
...
...
@@ -40,19 +41,14 @@ JMutex::~JMutex()
int
JMutex
::
Init
()
{
if
(
initialized
)
return
ERR_JMUTEX_ALREADYINIT
;
pthread_mutex_init
(
&
mutex
,
NULL
);
initialized
=
true
;
return
0
;
return
0
;
}
int
JMutex
::
Lock
()
{
if
(
!
initialized
)
return
ERR_JMUTEX_NOTINIT
;
pthread_mutex_lock
(
&
mutex
);
return
0
;
}
...
...
@@ -61,7 +57,7 @@ int JMutex::Unlock()
{
if
(
!
initialized
)
return
ERR_JMUTEX_NOTINIT
;
pthread_mutex_unlock
(
&
mutex
);
return
0
;
}
This diff is collapsed.
Click to expand it.
src/jthread/win32/jmutex.cpp
+
8
−
11
View file @
de0cdbc0
...
...
@@ -29,7 +29,14 @@
JMutex
::
JMutex
()
{
initialized
=
false
;
#ifdef JMUTEX_CRITICALSECTION
InitializeCriticalSection
(
&
mutex
);
#else
mutex
=
CreateMutex
(
NULL
,
FALSE
,
NULL
);
if
(
mutex
==
NULL
)
return
ERR_JMUTEX_CANTCREATEMUTEX
;
#endif // JMUTEX_CRITICALSECTION
initialized
=
true
;
}
JMutex
::~
JMutex
()
...
...
@@ -44,16 +51,6 @@ JMutex::~JMutex()
int
JMutex
::
Init
()
{
if
(
initialized
)
return
ERR_JMUTEX_ALREADYINIT
;
#ifdef JMUTEX_CRITICALSECTION
InitializeCriticalSection
(
&
mutex
);
#else
mutex
=
CreateMutex
(
NULL
,
FALSE
,
NULL
);
if
(
mutex
==
NULL
)
return
ERR_JMUTEX_CANTCREATEMUTEX
;
#endif // JMUTEX_CRITICALSECTION
initialized
=
true
;
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
src/log.cpp
+
6
−
1
View file @
de0cdbc0
...
...
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
std
::
list
<
ILogOutput
*>
log_outputs
[
LMT_NUM_VALUES
];
std
::
map
<
threadid_t
,
std
::
string
>
log_threadnames
;
JMutex
log_threadnamemutex
;
void
log_add_output
(
ILogOutput
*
out
,
enum
LogMessageLevel
lev
)
{
...
...
@@ -60,13 +61,17 @@ void log_remove_output(ILogOutput *out)
void
log_register_thread
(
const
std
::
string
&
name
)
{
threadid_t
id
=
get_current_thread_id
();
log_threadnamemutex
.
Lock
();
log_threadnames
[
id
]
=
name
;
log_threadnamemutex
.
Unlock
();
}
void
log_deregister_thread
()
{
threadid_t
id
=
get_current_thread_id
();
log_threadnamemutex
.
Lock
();
log_threadnames
.
erase
(
id
);
log_threadnamemutex
.
Unlock
();
}
static
std
::
string
get_lev_string
(
enum
LogMessageLevel
lev
)
...
...
@@ -144,7 +149,7 @@ class Logbuf : public std::streambuf
}
m_buf
+=
c
;
}
private
:
enum
LogMessageLevel
m_lev
;
std
::
string
m_buf
;
...
...
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