Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
clsync
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2015-05-21 20:36:52 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a1762f31c42cfc5601dd6903052e4760fafa7cf0
a1762f31
1 parent
a96d68fc
[hllock] Fixed a deadlock
Fixed a regression made by
a96d68fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
35 deletions
main.c
privileged.c
main.c
View file @
a1762f3
...
...
@@ -392,7 +392,7 @@ int syntax() {
}
int
ncpus
;
pid_t
parent_pid
;
pid_t
parent_pid
=
0
;
pid_t
waitpid_timed
(
pid_t
child_pid
,
int
*
status_p
,
long
sec
,
long
nsec
)
{
struct
timespec
ts
;
...
...
privileged.c
View file @
a1762f3
...
...
@@ -713,6 +713,39 @@ int pa_unsetup(struct pa_options *opts) {
return
0
;
}
static
int
helper_isalive_cache
;
static
inline
int
helper_isalive_proc
()
{
int
rc
;
debug
(
12
,
"helper_pid == %u"
,
helper_pid
);
if
((
rc
=
waitpid
(
helper_pid
,
NULL
,
WNOHANG
))
>=
0
)
return
helper_isalive_cache
=
1
;
debug
(
1
,
"waitpid(%u, NULL, WNOHANG) => %i"
,
helper_pid
,
rc
);
return
helper_isalive_cache
=
0
;
}
static
inline
int
helper_isalive_thread
()
{
int
rc
;
debug
(
12
,
""
);
if
((
rc
=
pthread_kill
(
privileged_thread
,
0
)))
return
helper_isalive_cache
=
0
;
debug
(
1
,
"pthread_kill(privileged_thread, 0) => %i"
,
helper_pid
,
rc
);
return
helper_isalive_cache
=
1
;
}
static
inline
int
helper_isalive
()
{
return
helper_pid
?
helper_isalive_proc
()
:
helper_isalive_thread
();
}
int
privileged_check
()
{
if
(
helper_pid
)
critical_on
(
!
helper_isalive_proc
());
return
0
;
}
# ifdef HL_LOCKS
static
inline
int
hl_isanswered
(
int
lockid
)
{
...
...
@@ -728,11 +761,24 @@ static inline void hl_setstate(int lockid, hllock_state_t stateid) {
}
int
hl_setstate_ifstate
(
int
lockid
,
hllock_state_t
stateid_new
,
hllock_state_t
stateid_old_mask
)
{
static
long
long
counter
=
0
;
volatile
int
*
local_lock_p
=
&
hl_lock_p
->
locallock_hl_setstate_ifstate
;
debug
(
90
,
"%i, 0x%o, 0x%o"
,
lockid
,
stateid_new
,
stateid_old_mask
);
if
(
!
g_atomic_int_dec_and_test
(
local_lock_p
))
if
(
helper_pid
||
parent_pid
)
{
if
(((
++
counter
)
&
0xffffff
)
==
0
)
{
if
(
helper_pid
)
{
critical_on
(
!
helper_isalive_proc
());
}
else
{
critical_on
(
!
parent_isalive
());
}
}
}
if
(
!
g_atomic_int_dec_and_test
(
local_lock_p
))
{
g_atomic_int_inc
(
local_lock_p
);
return
0
;
}
if
(
!
(
hl_lock_p
->
state
[
lockid
]
&
stateid_old_mask
))
{
g_atomic_int_inc
(
local_lock_p
);
...
...
@@ -812,39 +858,6 @@ void hl_shutdown(int lockid) {
# endif
static
int
helper_isalive_cache
;
static
inline
int
helper_isalive_proc
()
{
int
rc
;
debug
(
12
,
"helper_pid == %u"
,
helper_pid
);
if
((
rc
=
waitpid
(
helper_pid
,
NULL
,
WNOHANG
))
>=
0
)
return
helper_isalive_cache
=
1
;
debug
(
1
,
"waitpid(%u, NULL, WNOHANG) => %i"
,
helper_pid
,
rc
);
return
helper_isalive_cache
=
0
;
}
static
inline
int
helper_isalive_thread
()
{
int
rc
;
debug
(
12
,
""
);
if
((
rc
=
pthread_kill
(
privileged_thread
,
0
)))
return
helper_isalive_cache
=
0
;
debug
(
1
,
"pthread_kill(privileged_thread, 0) => %i"
,
helper_pid
,
rc
);
return
helper_isalive_cache
=
1
;
}
static
inline
int
helper_isalive
()
{
return
helper_pid
?
helper_isalive_proc
()
:
helper_isalive_thread
();
}
int
privileged_check
()
{
if
(
helper_pid
)
critical_on
(
!
helper_isalive_proc
());
return
0
;
}
int
privileged_handler
(
ctx_t
*
ctx_p
)
{
# ifdef READWRITE_SIGNALLING
...
...
Please
register
or
login
to post a comment