Changes for Dev
This commit is contained in:
parent
fa2ff487ff
commit
5509b7c03e
3 changed files with 32 additions and 15 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -499,9 +499,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.5.0"
|
version = "1.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aws-lc-rs"
|
name = "aws-lc-rs"
|
||||||
|
|
@ -2917,9 +2917,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.149"
|
version = "1.0.150"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
|
@ -3608,7 +3608,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttp-core"
|
name = "ttp-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#3e3f939f64088cb01c13348b58c504593953ec0e"
|
source = "git+https://git.methanium.net/Tensamin/TTP.git#886edbf51d26636e46745c3637b80610df82f5dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
@ -3621,7 +3621,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttp-native"
|
name = "ttp-native"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.methanium.net/Tensamin/TTP.git#3e3f939f64088cb01c13348b58c504593953ec0e"
|
source = "git+https://git.methanium.net/Tensamin/TTP.git#886edbf51d26636e46745c3637b80610df82f5dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quinn",
|
"quinn",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
|
|
||||||
18
src/main.rs
18
src/main.rs
|
|
@ -44,14 +44,14 @@ async fn main() {
|
||||||
.and_then(|s| s.parse().ok())
|
.and_then(|s| s.parse().ok())
|
||||||
.unwrap_or(9187);
|
.unwrap_or(9187);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
let omikron_handle = tokio::spawn(async move {
|
||||||
match omikron_connection::start(omikron_port).await {
|
match omikron_connection::start(omikron_port).await {
|
||||||
Err(e) => log_err!(0, PrintType::General, "{:?}", e),
|
Err(e) => log_err!(0, PrintType::General, "{:?}", e),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tokio::spawn(async move {
|
let tauri_handle = tokio::spawn(async move {
|
||||||
match tauri::start(9189).await {
|
match tauri::start(9189).await {
|
||||||
Err(e) => log_err!(0, PrintType::General, "{:?}", e),
|
Err(e) => log_err!(0, PrintType::General, "{:?}", e),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -80,7 +80,17 @@ async fn main() {
|
||||||
.and_then(|s| s.parse().ok())
|
.and_then(|s| s.parse().ok())
|
||||||
.unwrap_or(9188);
|
.unwrap_or(9188);
|
||||||
|
|
||||||
let _ = server::server::start(api_port).await;
|
tokio::select! {
|
||||||
|
result = server::server::start(api_port) => {
|
||||||
|
if let Err(e) = result {
|
||||||
|
log_err!(0, PrintType::General, "Server error: {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = tokio::signal::ctrl_c() => {
|
||||||
|
log!("Shutting down on signal...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tokio::signal::ctrl_c().await.unwrap();
|
omikron_handle.abort();
|
||||||
|
tauri_handle.abort();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,15 @@ pub struct OmikronConnection {
|
||||||
pub_key: RwLock<Option<Vec<u8>>>,
|
pub_key: RwLock<Option<Vec<u8>>>,
|
||||||
pub ping: RwLock<i64>,
|
pub ping: RwLock<i64>,
|
||||||
waiting_tasks: DashMap<u32, WaitingTask>,
|
waiting_tasks: DashMap<u32, WaitingTask>,
|
||||||
cleanup_handle: Mutex<Option<tokio::task::JoinHandle<()>>>,
|
cleanup_handle: std::sync::Mutex<Option<tokio::task::JoinHandle<()>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for OmikronConnection {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Some(handle) = self.cleanup_handle.lock().unwrap().take() {
|
||||||
|
handle.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OmikronConnection {
|
impl OmikronConnection {
|
||||||
|
|
@ -120,7 +128,7 @@ impl OmikronConnection {
|
||||||
pub_key: RwLock::new(None),
|
pub_key: RwLock::new(None),
|
||||||
ping: RwLock::new(-1),
|
ping: RwLock::new(-1),
|
||||||
waiting_tasks: DashMap::new(),
|
waiting_tasks: DashMap::new(),
|
||||||
cleanup_handle: Mutex::new(None),
|
cleanup_handle: std::sync::Mutex::new(None),
|
||||||
});
|
});
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
@ -148,7 +156,7 @@ impl OmikronConnection {
|
||||||
.retain(|_, v| v.inserted_at.elapsed() < MAX_WAITING_AGE);
|
.retain(|_, v| v.inserted_at.elapsed() < MAX_WAITING_AGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*self.cleanup_handle.lock().await = Some(cleanup_handle);
|
*self.cleanup_handle.lock().unwrap() = Some(cleanup_handle);
|
||||||
|
|
||||||
while let Ok(cv) = receiver.receive().await {
|
while let Ok(cv) = receiver.receive().await {
|
||||||
if let Err(e) = self.clone().process_message(cv).await {
|
if let Err(e) = self.clone().process_message(cv).await {
|
||||||
|
|
@ -1114,8 +1122,7 @@ impl OmikronConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel cleanup task
|
if let Some(handle) = self.cleanup_handle.lock().unwrap().take() {
|
||||||
if let Some(handle) = self.cleanup_handle.lock().await.take() {
|
|
||||||
handle.abort();
|
handle.abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue