diff --git a/hostd/src/main.rs b/hostd/src/main.rs index 9df041a..02d26db 100644 --- a/hostd/src/main.rs +++ b/hostd/src/main.rs @@ -1,4 +1,8 @@ -use std::{collections::HashMap, process::exit}; +use std::{ + collections::HashMap, + process::exit, + sync::{Arc, RwLock}, +}; use crate::io_patagia_Hostd::{ Call_Apply, Call_Describe, Label, Machine, PatagiaAgentConfig, VarlinkInterface, @@ -6,7 +10,9 @@ use crate::io_patagia_Hostd::{ mod io_patagia_Hostd; -struct Hostd; +struct Hostd { + pub state: Arc<RwLock<i64>>, +} impl VarlinkInterface for Hostd { fn apply(&self, call: &mut dyn Call_Apply, machine: Machine) -> varlink::Result<()> { @@ -31,7 +37,8 @@ impl VarlinkInterface for Hostd { } fn main() { - let hostd = Hostd; + let state = Arc::new(RwLock::new(0)); + let hostd = Hostd { state }; let hostd_interface = io_patagia_Hostd::new(Box::new(hostd)); let svc = varlink::VarlinkService::new( @@ -45,7 +52,7 @@ fn main() { svc, "unix:/tmp/io.patagia.Hostd", &varlink::ListenConfig { - idle_timeout: 0, + idle_timeout: 1, ..Default::default() }, );