Skip to content

Commit 58ce030

Browse files
committed
Notice immediately in Android entry
1 parent 48fac41 commit 58ce030

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/android.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,13 @@ pub mod native {
148148
/// Run the overtls client with config file.
149149
#[no_mangle]
150150
pub unsafe extern "C" fn Java_com_github_shadowsocks_bg_OverTlsWrapper_runClient(
151-
env: JNIEnv,
151+
mut env: JNIEnv,
152152
class: JClass,
153153
vpn_service: JObject,
154154
config_path: JString,
155155
stat_path: JString,
156156
verbosity: jint,
157157
) -> jint {
158-
let shutdown_token = crate::CancellationToken::new();
159-
{
160-
let mut lock = EXITING_FLAG.lock().unwrap();
161-
if lock.is_some() {
162-
log::error!("tun2proxy already started");
163-
return -1;
164-
}
165-
*lock = Some(shutdown_token.clone());
166-
}
167-
168-
let mut env = env;
169-
170158
let log_level = ArgVerbosity::try_from(verbosity).unwrap().to_string();
171159
let root = module_path!().split("::").next().unwrap();
172160
let filter_str = &format!("off,{root}={log_level}");
@@ -178,10 +166,22 @@ pub mod native {
178166
.with_filter(filter),
179167
);
180168

169+
log::info!("Starting overtls client on Android");
170+
171+
let shutdown_token = crate::CancellationToken::new();
172+
{
173+
let mut lock = EXITING_FLAG.lock().unwrap();
174+
if lock.is_some() {
175+
log::error!("overtls already started");
176+
return -1;
177+
}
178+
*lock = Some(shutdown_token.clone());
179+
}
180+
181181
let block = || -> Result<()> {
182182
if let Ok(stat_path) = get_java_string(&mut env, &stat_path) {
183-
let mut stat = STAT_PATH.write().unwrap();
184-
*stat = stat_path.to_owned();
183+
let mut stat = STAT_PATH.write().map_err(|e| Error::from(e.to_string()))?;
184+
*stat = stat_path;
185185
}
186186
let config_path = get_java_string(&mut env, &config_path)?.to_owned();
187187
set_panic_handler();

0 commit comments

Comments
 (0)