From 6f873a4bc9d9fb16fd753e6150e5dfb07d4fb163 Mon Sep 17 00:00:00 2001 From: Val Lorentz Date: Sat, 13 Apr 2024 11:30:24 +0200 Subject: [PATCH] Reload info strings on ircd restart instead of serializing the loaded strings in the server state --- sable_ircd/src/server/server_type.rs | 5 ++--- sable_server/src/server.rs | 6 +++++- sable_server/src/server_type.rs | 1 + sable_services/src/server/mod.rs | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sable_ircd/src/server/server_type.rs b/sable_ircd/src/server/server_type.rs index e0adcfb8..bb07b2b7 100644 --- a/sable_ircd/src/server/server_type.rs +++ b/sable_ircd/src/server/server_type.rs @@ -12,7 +12,6 @@ pub struct ClientServerState { auth_state: AuthClientState, client_caps: CapabilityRepository, listener_state: SavedListenerCollection, - info_strings: config::ServerInfoStrings, } #[async_trait] @@ -107,7 +106,6 @@ impl sable_server::ServerType for ClientServer { .save() .await .map_err(ServerSaveError::IoError)?, - info_strings: self.info_strings, }) } @@ -116,6 +114,7 @@ impl sable_server::ServerType for ClientServer { state: ClientServerState, node: Arc, history_receiver: UnboundedReceiver, + config: &Self::ProcessedConfig, ) -> std::io::Result { let (auth_send, auth_recv) = unbounded_channel(); let (action_send, action_recv) = unbounded_channel(); @@ -148,7 +147,7 @@ impl sable_server::ServerType for ClientServer { client_caps: state.client_caps, history_receiver: Mutex::new(history_receiver), listeners: Movable::new(listeners), - info_strings: state.info_strings, + info_strings: config.info_strings.clone(), }) } diff --git a/sable_server/src/server.rs b/sable_server/src/server.rs index 3319f142..5dd9cf78 100644 --- a/sable_server/src/server.rs +++ b/sable_server/src/server.rs @@ -318,11 +318,14 @@ where state: ServerState, net_config: SyncConfig, server_config: ServerConfig, - ) -> std::io::Result { + ) -> Result { let (server_send, server_recv) = unbounded_channel(); let (history_send, history_recv) = unbounded_channel(); let (remote_send, remote_recv) = unbounded_channel(); + let processed_server_config = ST::validate_config(&server_config.server) + .context("Could not load server configuration")?; + let log = Arc::new(ReplicatedEventLog::restore( state.log_state, server_send, @@ -342,6 +345,7 @@ where state.server_state, Arc::clone(&node), history_recv, + &processed_server_config, )?); Ok(Self { diff --git a/sable_server/src/server_type.rs b/sable_server/src/server_type.rs index c53c40b8..5aa34ce2 100644 --- a/sable_server/src/server_type.rs +++ b/sable_server/src/server_type.rs @@ -59,6 +59,7 @@ pub trait ServerType: Send + Sync + Sized + 'static { state: Self::Saved, node: Arc, history_receiver: UnboundedReceiver, + config: &Self::ProcessedConfig, ) -> std::io::Result; /// Handle a request originating from a remote server diff --git a/sable_services/src/server/mod.rs b/sable_services/src/server/mod.rs index 355a0baa..5f611e15 100644 --- a/sable_services/src/server/mod.rs +++ b/sable_services/src/server/mod.rs @@ -147,6 +147,7 @@ where _state: Self::Saved, _node: Arc, _history_receiver: UnboundedReceiver, + _config: &Self::ProcessedConfig, ) -> std::io::Result { unimplemented!("services can't hot-upgrade"); }