Skip to content
Snippets Groups Projects
Commit 5a6eb681 authored by Jan-Erik Rediger's avatar Jan-Erik Rediger
Browse files

Bug 1659109 - Initiate shutdown of the dispatcher. r=chutten

parent deace8ef
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,8 @@ pub mod ping_upload;
pub mod pings;
pub mod private;
pub mod ipc;
pub(crate) mod dispatcher;
pub mod ipc;
/// Run a closure with a mutable reference to the locked global Glean object.
fn with_glean<F, R>(f: F) -> R
......@@ -45,3 +45,9 @@ pub fn is_upload_enabled() -> bool {
pub fn flush_init() -> Result<(), dispatcher::DispatchError> {
dispatcher::flush_init()
}
pub fn shutdown() {
if let Err(e) = dispatcher::try_shutdown() {
log::error!("Can't shutdown dispatcher thread: {:?}", e);
}
}
......@@ -125,6 +125,11 @@ pub unsafe extern "C" fn fog_init() -> nsresult {
NS_OK
}
#[no_mangle]
pub unsafe extern "C" fn fog_shutdown() {
fog::shutdown();
}
/// Construct and return the data_path from the profile dir, or return an error.
fn get_data_path() -> Result<String, nsresult> {
let dir_svc = match xpcom::services::get_DirectoryService() {
......
......@@ -20,17 +20,23 @@ already_AddRefed<FOG> FOG::GetSingleton() {
}
gFOG = new FOG();
ClearOnShutdown(&gFOG);
RunOnShutdown([&] {
gFOG->Shutdown();
gFOG = nullptr;
});
return do_AddRef(gFOG);
}
extern "C" {
nsresult fog_init();
void fog_shutdown();
nsresult fog_set_log_pings(bool aEnableLogPings);
nsresult fog_set_debug_view_tag(const nsACString* aDebugTag);
nsresult fog_submit_ping(const nsACString* aPingName);
}
void FOG::Shutdown() { fog_shutdown(); }
NS_IMETHODIMP
FOG::InitializeFOG() { return fog_init(); }
......
......@@ -19,6 +19,7 @@ class FOG final : public nsIFOG {
private:
~FOG() = default;
void Shutdown();
};
}; // namespace mozilla
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment