Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
abb97e16
Commit
abb97e16
authored
Jul 24, 2015
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
play tricks to close fd manually
parent
541f8de2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
0 deletions
+10
-0
src/main/java/com/github/shadowsocks/System.java
src/main/java/com/github/shadowsocks/System.java
+1
-0
src/main/jni/system.cpp
src/main/jni/system.cpp
+6
-0
src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
...n/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
+3
-0
No files found.
src/main/java/com/github/shadowsocks/System.java
View file @
abb97e16
...
@@ -46,4 +46,5 @@ public class System {
...
@@ -46,4 +46,5 @@ public class System {
public
static
native
void
exec
(
String
cmd
);
public
static
native
void
exec
(
String
cmd
);
public
static
native
String
getABI
();
public
static
native
String
getABI
();
public
static
native
int
sendfd
(
int
fd
);
public
static
native
int
sendfd
(
int
fd
);
public
static
native
void
jniclose
(
int
fd
);
}
}
src/main/jni/system.cpp
View file @
abb97e16
...
@@ -43,6 +43,10 @@ void Java_com_github_shadowsocks_system_exec(JNIEnv *env, jobject thiz, jstring
...
@@ -43,6 +43,10 @@ void Java_com_github_shadowsocks_system_exec(JNIEnv *env, jobject thiz, jstring
env
->
ReleaseStringUTFChars
(
cmd
,
str
);
env
->
ReleaseStringUTFChars
(
cmd
,
str
);
}
}
void
Java_com_github_shadowsocks_system_jniclose
(
JNIEnv
*
env
,
jobject
thiz
,
jint
fd
)
{
close
(
fd
);
}
jint
Java_com_github_shadowsocks_system_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
)
{
jint
Java_com_github_shadowsocks_system_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
)
{
int
fd
;
int
fd
;
struct
sockaddr_un
addr
;
struct
sockaddr_un
addr
;
...
@@ -75,6 +79,8 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
...
@@ -75,6 +79,8 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
static
const
char
*
classPathName
=
"com/github/shadowsocks/System"
;
static
const
char
*
classPathName
=
"com/github/shadowsocks/System"
;
static
JNINativeMethod
method_table
[]
=
{
static
JNINativeMethod
method_table
[]
=
{
{
"jniclose"
,
"(I)V"
,
(
void
*
)
Java_com_github_shadowsocks_system_jniclose
},
{
"sendfd"
,
"(I)I"
,
{
"sendfd"
,
"(I)I"
,
(
void
*
)
Java_com_github_shadowsocks_system_sendfd
},
(
void
*
)
Java_com_github_shadowsocks_system_sendfd
},
{
"exec"
,
"(Ljava/lang/String;)V"
,
{
"exec"
,
"(Ljava/lang/String;)V"
,
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
View file @
abb97e16
...
@@ -105,6 +105,9 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
...
@@ -105,6 +105,9 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
val
fd
=
getInt
.
invoke
(
fds
(
0
)).
asInstanceOf
[
Int
]
val
fd
=
getInt
.
invoke
(
fds
(
0
)).
asInstanceOf
[
Int
]
ret
=
vpnService
.
protect
(
fd
)
ret
=
vpnService
.
protect
(
fd
)
// Trick to close file decriptor
System
.
jniclose
(
fd
)
if
(
ret
)
{
if
(
ret
)
{
output
.
write
(
0
)
output
.
write
(
0
)
}
else
{
}
else
{
...
...
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