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
e8e39e0f
Commit
e8e39e0f
authored
Oct 04, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use poll instead of select
Close #637
parent
37860181
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
23 deletions
+23
-23
socket.c
native/jni/daemon/socket.c
+5
-17
su_daemon.c
native/jni/su/su_daemon.c
+8
-6
utils.h
native/jni/utils/include/utils.h
+2
-0
xwrap.c
native/jni/utils/xwrap.c
+8
-0
No files found.
native/jni/daemon/socket.c
View file @
e8e39e0f
...
@@ -40,23 +40,11 @@ int create_rand_socket(struct sockaddr_un *sun) {
...
@@ -40,23 +40,11 @@ int create_rand_socket(struct sockaddr_un *sun) {
}
}
int
socket_accept
(
int
sockfd
,
int
timeout
)
{
int
socket_accept
(
int
sockfd
,
int
timeout
)
{
struct
timeval
tv
;
struct
pollfd
pfd
=
{
fd_set
fds
;
.
fd
=
sockfd
,
int
rc
;
.
events
=
POLL_IN
};
tv
.
tv_sec
=
timeout
;
return
xpoll
(
&
pfd
,
1
,
timeout
*
1000
)
<=
0
?
-
1
:
xaccept4
(
sockfd
,
NULL
,
NULL
,
SOCK_CLOEXEC
);
tv
.
tv_usec
=
0
;
FD_ZERO
(
&
fds
);
FD_SET
(
sockfd
,
&
fds
);
do
{
rc
=
select
(
sockfd
+
1
,
&
fds
,
NULL
,
NULL
,
&
tv
);
}
while
(
rc
<
0
&&
errno
==
EINTR
);
if
(
rc
<
1
)
{
PLOGE
(
"select"
);
return
-
1
;
}
return
xaccept4
(
sockfd
,
NULL
,
NULL
,
SOCK_CLOEXEC
);
}
}
/*
/*
...
...
native/jni/su/su_daemon.c
View file @
e8e39e0f
...
@@ -168,12 +168,14 @@ static struct su_info *get_su_info(unsigned uid) {
...
@@ -168,12 +168,14 @@ static struct su_info *get_su_info(unsigned uid) {
// Connect manager
// Connect manager
app_connect
(
addr
.
sun_path
+
1
,
info
);
app_connect
(
addr
.
sun_path
+
1
,
info
);
int
fd
=
socket_accept
(
sockfd
,
60
);
int
fd
=
socket_accept
(
sockfd
,
60
);
if
(
fd
<
0
)
{
info
->
access
.
policy
=
DENY
;
}
else
{
socket_send_request
(
fd
,
info
);
socket_send_request
(
fd
,
info
);
int
ret
=
read_int_be
(
fd
);
int
ret
=
read_int_be
(
fd
);
info
->
access
.
policy
=
ret
<
0
?
DENY
:
ret
;
info
->
access
.
policy
=
ret
<
0
?
DENY
:
ret
;
close
(
fd
);
close
(
fd
);
}
close
(
sockfd
);
close
(
sockfd
);
}
}
...
...
native/jni/utils/include/utils.h
View file @
e8e39e0f
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdio.h>
#include <dirent.h>
#include <dirent.h>
#include <pthread.h>
#include <pthread.h>
#include <poll.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/stat.h>
...
@@ -78,6 +79,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags,
...
@@ -78,6 +79,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags,
int
fd
,
off_t
offset
);
int
fd
,
off_t
offset
);
ssize_t
xsendfile
(
int
out_fd
,
int
in_fd
,
off_t
*
offset
,
size_t
count
);
ssize_t
xsendfile
(
int
out_fd
,
int
in_fd
,
off_t
*
offset
,
size_t
count
);
pid_t
xfork
();
pid_t
xfork
();
int
xpoll
(
struct
pollfd
*
fds
,
nfds_t
nfds
,
int
timeout
);
// misc.c
// misc.c
...
...
native/jni/utils/xwrap.c
View file @
e8e39e0f
...
@@ -394,3 +394,11 @@ pid_t xfork() {
...
@@ -394,3 +394,11 @@ pid_t xfork() {
}
}
return
ret
;
return
ret
;
}
}
int
xpoll
(
struct
pollfd
*
fds
,
nfds_t
nfds
,
int
timeout
)
{
int
ret
=
poll
(
fds
,
nfds
,
timeout
);
if
(
ret
==
-
1
)
{
PLOGE
(
"poll"
);
}
return
ret
;
}
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