mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 07:57:38 +00:00
Update to new list implementation
This commit is contained in:
parent
c9286624d4
commit
7c4d5cee95
26
su_daemon.c
26
su_daemon.c
@ -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
|
||||||
if (node->clock == 0) {
|
__ = list_pop(&node->pos);
|
||||||
temp = pos;
|
list_insert_end(&waiting_list, &node->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) {
|
|||||||
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) {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user