mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 04:06:54 +00:00
refactor(admin): Release handle lock before command execution
Change admin service handle to SyncRwLock and copy the handler function pointer before awaiting execution to prevent deadlock.
This commit is contained in:
3 files changed
+13
-15
No files matched your search
+4
-8
@@ -39,17 +39,13 @@ conduwuit::mod_dtor! {}
|
||||
pub use crate::admin::AdminCommand;
|
||||
|
||||
/// Install the admin command processor
|
||||
pub async fn init(admin_service: &service::admin::Service) {
|
||||
pub fn init(admin_service: &service::admin::Service) {
|
||||
_ = admin_service.complete.write().insert(processor::complete);
|
||||
_ = admin_service
|
||||
.handle
|
||||
.write()
|
||||
.await
|
||||
.insert(processor::dispatch);
|
||||
_ = admin_service.handle.write().insert(processor::dispatch);
|
||||
}
|
||||
|
||||
/// Uninstall the admin command handler
|
||||
pub async fn fini(admin_service: &service::admin::Service) {
|
||||
_ = admin_service.handle.write().await.take();
|
||||
pub fn fini(admin_service: &service::admin::Service) {
|
||||
_ = admin_service.handle.write().take();
|
||||
_ = admin_service.complete.write().take();
|
||||
}
|
||||
Reference in new issue
Block a user