diff --git a/CHANGELOG.md b/CHANGELOG.md index a8e19c9..722dfe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.1.4 +## Bug fix +1. Fix segmentation fault when shared API is enabled. + # 0.1.3 ## Bug fix 1. Fix login db error when using PostgreSQL. diff --git a/docker-compose.yml b/docker-compose.yml index 3e13748..a7284f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: restart: always depends_on: - redis + - db volumes: - ./plugin/:/app/plugin - ./assets/_plugin/:/app/assets/_plugin diff --git a/skynet/src/lib.rs b/skynet/src/lib.rs index 50063b2..433cade 100644 --- a/skynet/src/lib.rs +++ b/skynet/src/lib.rs @@ -118,6 +118,13 @@ pub struct Skynet { pub shared_api: HashMap>, } +impl Drop for Skynet { + fn drop(&mut self) { + // clear API first otherwise SIGSEGV. + self.shared_api.clear(); + } +} + impl Skynet { #[allow(clippy::missing_panics_doc)] pub fn insert_menu(&mut self, item: MenuItem, pos: usize, parent: Option) -> bool { diff --git a/skynet/src/plugin.rs b/skynet/src/plugin.rs index 20b8152..c923dd0 100644 --- a/skynet/src/plugin.rs +++ b/skynet/src/plugin.rs @@ -156,6 +156,13 @@ pub struct PluginInstance { library: Option, } +impl Drop for PluginInstance { + fn drop(&mut self) { + self.instance = None; + self.library = None; + } +} + impl PluginInstance { /// Get setting name. #[must_use] @@ -293,7 +300,11 @@ impl PluginManager { let dll = dll.pop().unwrap_or_default(); let inst = Self::load_internal(path.as_ref().join(PLUGIN_CONFIG), dll)?; if let Some(x) = self.get(&inst.id) { - bail!(PluginError::ConflictID(x.id, inst.name, x.name.clone())); + bail!(PluginError::ConflictID( + x.id, + inst.name.clone(), + x.name.clone() + )); } skynet.setting.set(db, &inst.setting_name(), "0").await?; let mut wlock = self.plugin.write(); @@ -385,7 +396,7 @@ impl PluginManager { if let Some(x) = conflict_id.get(&obj.id) { panic!( "{}", - PluginError::ConflictID(obj.id, obj.name, x.to_owned()) + PluginError::ConflictID(obj.id, obj.name.clone(), x.to_owned()) ); } conflict_id.insert(obj.id, obj.name.clone());