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
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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);
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -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() {
+7 −1
Original line number Diff line number Diff line
@@ -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(); }

+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ class FOG final : public nsIFOG {

 private:
  ~FOG() = default;
  void Shutdown();
};

};  // namespace mozilla