let r = otter::session::mount(r);
let r = otter::api::mount(r);
+
+ thread::spawn(client_periodic_expiry);
+
r.launch();
}
}
}
-// ---------- client expiry ---------- xxx not working
+// ---------- client expiry ----------
-pub fn client_expire_old_clients() {
+fn client_expire_old_clients() {
fn lock_even_poisoned(gref: &InstanceRef) -> MutexGuard<InstanceContainer> {
match gref.0.lock() {
Ok(g) => g,
}
}
+pub fn client_periodic_expiry() {
+ loop {
+ sleep(MAX_CLIENT_INACTIVITY);
+ client_expire_old_clients();
+ }
+}
+
// ========== server config ==========
const DEFAULT_CONFIG_FILENAME : &str = "server.toml";
pub use std::fmt::Write as _;
pub use std::fmt::Formatter;
pub use std::fmt::{self,Display,Debug};
-pub use std::thread;
+pub use std::thread::{self,sleep};
pub use std::time::Duration;
pub use std::sync::{Arc,Mutex,MutexGuard,RwLock,RwLockReadGuard,Condvar};
pub use std::collections::{HashMap,hash_map,HashSet};