mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-04-19 15:25:54 -04:00
Merge branch 'single-startup-dart' into 'main'
don't panic during abnormal shutdown See merge request veilid/veilid!393
This commit is contained in:
commit
72b1434abc
@ -284,7 +284,6 @@ pub async fn api_startup_config(
|
||||
|
||||
// Only allow one startup/shutdown per program_name+namespace combination simultaneously
|
||||
let _tag_guard = STARTUP_TABLE.lock_tag(init_key.clone()).await;
|
||||
|
||||
// See if we have an API started up already
|
||||
if INITIALIZED.lock().contains(&init_key) {
|
||||
apibail_already_initialized!();
|
||||
|
@ -531,10 +531,11 @@ impl TableStore {
|
||||
let mut inner = self.inner.lock();
|
||||
inner.opened.shrink_to_fit();
|
||||
if !inner.opened.is_empty() {
|
||||
panic!(
|
||||
veilid_log!(self warn
|
||||
"all open databases should have been closed: {:?}",
|
||||
inner.opened
|
||||
);
|
||||
inner.opened.clear();
|
||||
}
|
||||
inner.all_tables_db = None;
|
||||
inner.all_table_names.clear();
|
||||
|
@ -78,13 +78,6 @@ async fn get_veilid_api() -> veilid_core::VeilidAPIResult<veilid_core::VeilidAPI
|
||||
.ok_or(veilid_core::VeilidAPIError::NotInitialized)
|
||||
}
|
||||
|
||||
async fn take_veilid_api() -> veilid_core::VeilidAPIResult<veilid_core::VeilidAPI> {
|
||||
let mut api_lock = VEILID_API.lock().await;
|
||||
api_lock
|
||||
.take()
|
||||
.ok_or(veilid_core::VeilidAPIError::NotInitialized)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
// FFI Helpers
|
||||
|
||||
@ -513,7 +506,10 @@ pub extern "C" fn detach(port: i64) {
|
||||
pub extern "C" fn shutdown_veilid_core(port: i64) {
|
||||
DartIsolateWrapper::new(port).spawn_result(
|
||||
async move {
|
||||
let veilid_api = take_veilid_api().await?;
|
||||
let mut api_lock = VEILID_API.lock().await;
|
||||
let veilid_api = api_lock
|
||||
.take()
|
||||
.ok_or(veilid_core::VeilidAPIError::NotInitialized)?;
|
||||
veilid_api.shutdown().await;
|
||||
APIRESULT_VOID
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user