summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2020-06-20 12:15:59 -0700
committerStuart Stock <stuart@int08h.com>2020-06-20 12:15:59 -0700
commit93041341c85b7f3beb5b0afdf3900fc8a1387ab9 (patch)
tree5c5e9a3f37940e80d9655e7dfd2aa040617edef9
parent926b8c6916b6219998ac6d66a93dd00764579321 (diff)
downloadroughenough-93041341c85b7f3beb5b0afdf3900fc8a1387ab9.zip
cleanups: tidy server code; extract configuration display to own function
-rw-r--r--src/bin/roughenough-server.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/bin/roughenough-server.rs b/src/bin/roughenough-server.rs
index 8a086e7..46fd7b4 100644
--- a/src/bin/roughenough-server.rs
+++ b/src/bin/roughenough-server.rs
@@ -45,8 +45,26 @@ macro_rules! check_ctrlc {
fn polling_loop(config: Box<dyn ServerConfig>) {
let mut server = Server::new(config);
- let cfg = server.get_config(); // borrow config that was moved above
+ let cfg = server.get_config();
+ display_config(&server, cfg);
+ let kr = server.get_keep_running();
+ let kr0 = kr.clone();
+
+ ctrlc::set_handler(move || kr.store(false, Ordering::Release))
+ .expect("failed setting Ctrl-C handler");
+
+ let mut events = Events::with_capacity(1024);
+
+ loop {
+ check_ctrlc!(kr0);
+ if server.process_events(&mut events) {
+ return;
+ }
+ }
+}
+
+fn display_config(server: &Server, cfg: &dyn ServerConfig) {
info!("Long-term public key : {}", server.get_public_key());
info!("Online public key : {}", server.get_online_key());
info!("Max response batch size : {}", cfg.batch_size());
@@ -65,21 +83,6 @@ fn polling_loop(config: Box<dyn ServerConfig>) {
} else {
info!("Deliberate response errors : disabled");
}
-
- let kr = server.get_keep_running();
- let kr_new = kr.clone();
-
- ctrlc::set_handler(move || kr.store(false, Ordering::Release))
- .expect("failed setting Ctrl-C handler");
-
- let mut events = Events::with_capacity(64);
-
- loop {
- check_ctrlc!(kr_new);
- if server.process_events(&mut events) {
- return;
- }
- }
}
pub fn main() {