Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
b763b81f
Commit
b763b81f
authored
Sep 26, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use mutex_guard to lock su_info
parent
947dae49
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
12 deletions
+5
-12
su.h
native/jni/su/su.h
+2
-2
su_daemon.cpp
native/jni/su/su_daemon.cpp
+3
-10
No files found.
native/jni/su/su.h
View file @
b763b81f
...
...
@@ -5,6 +5,7 @@
#include <memory>
#include <db.h>
#include <utils.h>
#define DEFAULT_SHELL "/system/bin/sh"
...
...
@@ -29,8 +30,7 @@ public:
su_info
(
unsigned
uid
=
0
);
~
su_info
();
void
lock
();
void
unlock
();
mutex_guard
lock
();
bool
is_fresh
();
void
refresh
();
...
...
native/jni/su/su_daemon.cpp
View file @
b763b81f
...
...
@@ -33,12 +33,8 @@ su_info::~su_info() {
pthread_mutex_destroy
(
&
_lock
);
}
void
su_info
::
lock
()
{
pthread_mutex_lock
(
&
_lock
);
}
void
su_info
::
unlock
()
{
pthread_mutex_unlock
(
&
_lock
);
mutex_guard
su_info
::
lock
()
{
return
mutex_guard
(
_lock
);
}
bool
su_info
::
is_fresh
()
{
...
...
@@ -96,10 +92,7 @@ static shared_ptr<su_info> get_su_info(unsigned uid) {
info
=
cached
;
}
info
->
lock
();
run_finally
unlock
([
&
]
{
info
->
unlock
();
});
auto
g
=
info
->
lock
();
if
(
info
->
access
.
policy
==
QUERY
)
{
// Not cached, get data from database
...
...
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