Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
92b6c650
Commit
92b6c650
authored
Aug 13, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect contention-detection logging with a global static mutex
parent
ddbf3004
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+12
-2
No files found.
Cython/Utility/CyObjects.cpp
View file @
92b6c650
...
...
@@ -60,10 +60,12 @@
};
class
LogLock
:
public
RecursiveUpgradeableRWLock
{
static
pthread_mutex_t
log_guard
;
public:
void
wlock
();
void
rlock
();
};
pthread_mutex_t
LogLock
::
log_guard
=
PTHREAD_MUTEX_INITIALIZER
;
struct
CyPyObject
{
PyObject_HEAD
...
...
@@ -477,12 +479,14 @@ void LogLock::rlock() {
if
(
this
->
write_count
>
0
)
{
pid_t
owner_id
=
this
->
owner_id
;
pthread_mutex_lock
(
&
(
LogLock
::
log_guard
));
printf
(
"Contention with a writer detected while rlocking lock [%p] in thread #%d:
\n
"
" - lock was already wlocked by thread %d
\n
"
"
\n
"
,
this
,
caller_id
,
owner_id
);
pthread_mutex_unlock
(
&
(
LogLock
::
log_guard
));
}
while
(
this
->
write_count
>
0
)
{
...
...
@@ -513,19 +517,23 @@ void LogLock::wlock() {
if
(
this
->
readers_nb
>
0
)
{
if
(
owner_id
==
CyObject_MANY_OWNERS
)
{
pthread_mutex_lock
(
&
(
LogLock
::
log_guard
));
printf
(
"Contention with several other reader threads detected while wlocking lock [%p] in thread #%d:
\n
"
"
\n
"
,
this
,
caller_id
);
}
pthread_mutex_unlock
(
&
(
LogLock
::
log_guard
));
}
else
{
pthread_mutex_lock
(
&
(
LogLock
::
log_guard
));
printf
(
"Contention with a reader thread detected while wlocking lock [%p] in thread #%d:
\n
"
" - reader thread is %d
\n
"
"
\n
"
,
this
,
caller_id
,
owner_id
);
pthread_mutex_unlock
(
&
(
LogLock
::
log_guard
));
}
}
...
...
@@ -534,12 +542,14 @@ void LogLock::wlock() {
}
if
(
this
->
write_count
>
0
)
{
pthread_mutex_lock
(
&
(
LogLock
::
log_guard
));
printf
(
"Contention with another writer detected while wlocking lock [%p] in thread #%d:
\n
"
" - lock
owner is
thread %d
\n
"
" - lock
was already wlocked by
thread %d
\n
"
"
\n
"
,
this
,
caller_id
,
owner_id
);
pthread_mutex_unlock
(
&
(
LogLock
::
log_guard
));
}
while
(
this
->
write_count
>
0
)
{
...
...
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