Skip to content

Commit

Permalink
android: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
eycorsican committed Oct 11, 2023
1 parent b92e08a commit fcb0879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions leaf/src/mobile/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub mod android {

use anyhow::{anyhow, Result};
use jni::{objects::*, JavaVM};
use parking_lot::RwLock;
use std::sync::RwLock;

static JVM: RwLock<Option<JavaVM>> = RwLock::new(None);
static CALLBACK_PROTECT_SOCKET: RwLock<Option<CallbackProtectSocket>> = RwLock::new(None);
Expand All @@ -55,31 +55,31 @@ pub mod android {
}

pub fn set_jvm(vm: JavaVM) {
*JVM.write() = Some(vm);
*JVM.write().unwrap() = Some(vm);
}

pub fn unset_jvm() {
*JVM.write() = None;
*JVM.write().unwrap() = None;
}

pub fn set_protect_socket_callback(class: GlobalRef, name: String) {
*CALLBACK_PROTECT_SOCKET.write() = Some(CallbackProtectSocket { class, name });
*CALLBACK_PROTECT_SOCKET.write().unwrap() = Some(CallbackProtectSocket { class, name });
}

pub fn unset_protect_socket_callback() {
*CALLBACK_PROTECT_SOCKET.write() = None;
*CALLBACK_PROTECT_SOCKET.write().unwrap() = None;
}

pub fn is_protect_socket_callback_set() -> bool {
CALLBACK_PROTECT_SOCKET.read().is_some()
CALLBACK_PROTECT_SOCKET.read().unwrap().is_some()
}

pub fn protect_socket(fd: RawFd) -> Result<()> {
let jvm_g = JVM.read();
let jvm_g = JVM.read().unwrap();
let Some(vm) = jvm_g.as_ref() else {
return Err(anyhow!("Java VM not set"));
};
let cb_g = CALLBACK_PROTECT_SOCKET.read();
let cb_g = CALLBACK_PROTECT_SOCKET.read().unwrap();
let Some(cb) = cb_g.as_ref() else {
return Err(anyhow!("protect socket callback not set"));
};
Expand Down
2 changes: 1 addition & 1 deletion leaf/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async fn protect_socket(fd: RawFd) -> io::Result<()> {
format!("failed to protect outbound socket {}: {:?}", fd, e),
)
})?;
log::debug!(
trace!(
"protected socket {} in {} µs",
fd,
start.elapsed().as_micros()
Expand Down

0 comments on commit fcb0879

Please sign in to comment.