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
7c4d5cee
Commit
7c4d5cee
authored
Jul 02, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to new list implementation
parent
c9286624
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
su_daemon.c
su_daemon.c
+9
-19
No files found.
su_daemon.c
View file @
7c4d5cee
...
@@ -67,29 +67,21 @@ static void sigpipe_handler(int sig) {
...
@@ -67,29 +67,21 @@ static void sigpipe_handler(int sig) {
// Maintain the lists periodically
// Maintain the lists periodically
static
void
*
collector
(
void
*
args
)
{
static
void
*
collector
(
void
*
args
)
{
LOGD
(
"su: collector started
\n
"
);
LOGD
(
"su: collector started
\n
"
);
struct
list_head
*
pos
,
*
temp
;
struct
su_info
*
node
;
struct
su_info
*
node
;
while
(
1
)
{
while
(
1
)
{
sleep
(
1
);
sleep
(
1
);
pthread_mutex_lock
(
&
list_lock
);
pthread_mutex_lock
(
&
list_lock
);
list_for_each
(
pos
,
&
active_list
)
{
list_for_each
(
node
,
&
active_list
,
struct
su_info
,
pos
)
{
node
=
list_entry
(
pos
,
struct
su_info
,
pos
);
if
(
--
node
->
clock
==
0
)
{
--
node
->
clock
;
// Timeout, move to waiting list
// Timeout, move to waiting list
__
=
list_pop
(
&
node
->
pos
);
if
(
node
->
clock
==
0
)
{
list_insert_end
(
&
waiting_list
,
&
node
->
pos
);
temp
=
pos
;
pos
=
pos
->
prev
;
list_pop
(
temp
);
list_insert_end
(
&
waiting_list
,
temp
);
}
}
}
}
list_for_each
(
pos
,
&
waiting_list
)
{
list_for_each
(
node
,
&
waiting_list
,
struct
su_info
,
pos
)
{
node
=
list_entry
(
pos
,
struct
su_info
,
pos
);
// Nothing is using the info, remove it
if
(
node
->
count
==
0
)
{
if
(
node
->
count
==
0
)
{
temp
=
pos
;
// Nothing is using the info, remove it
pos
=
pos
->
prev
;
__
=
list_pop
(
&
node
->
pos
);
list_pop
(
temp
);
pthread_mutex_destroy
(
&
node
->
lock
);
pthread_mutex_destroy
(
&
node
->
lock
);
free
(
node
);
free
(
node
);
}
}
...
@@ -102,7 +94,6 @@ void su_daemon_receiver(int client) {
...
@@ -102,7 +94,6 @@ void su_daemon_receiver(int client) {
LOGD
(
"su: request from client: %d
\n
"
,
client
);
LOGD
(
"su: request from client: %d
\n
"
,
client
);
struct
su_info
*
info
=
NULL
,
*
node
;
struct
su_info
*
info
=
NULL
,
*
node
;
struct
list_head
*
pos
;
int
new_request
=
0
;
int
new_request
=
0
;
pthread_mutex_lock
(
&
list_lock
);
pthread_mutex_lock
(
&
list_lock
);
...
@@ -118,8 +109,7 @@ void su_daemon_receiver(int client) {
...
@@ -118,8 +109,7 @@ void su_daemon_receiver(int client) {
get_client_cred
(
client
,
&
credential
);
get_client_cred
(
client
,
&
credential
);
// Search for existing in the active list
// Search for existing in the active list
list_for_each
(
pos
,
&
active_list
)
{
list_for_each
(
node
,
&
active_list
,
struct
su_info
,
pos
)
{
node
=
list_entry
(
pos
,
struct
su_info
,
pos
);
if
(
node
->
uid
==
credential
.
uid
)
if
(
node
->
uid
==
credential
.
uid
)
info
=
node
;
info
=
node
;
}
}
...
...
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