From 8f0b907808734437a51c8f2f05f96dcb498c0dd8 Mon Sep 17 00:00:00 2001 From: Sandor Molnar Date: Wed, 15 Nov 2023 19:33:12 +0200 Subject: [PATCH] Backed out 3 changesets (bug 1837907) for causing xpc failures on toolkit/mozapps/update/tests/unit_base_updater/marSuccessPartialWhileBackgroundTaskRunning.js Backed out changeset 28174e34160b (bug 1837907) Backed out changeset a883cbc99803 (bug 1837907) Backed out changeset 7a2134520f7c (bug 1837907) --- toolkit/profile/nsProfileLock.cpp | 5 +++ widget/gtk/nsAppShell.cpp | 55 ++----------------------------- widget/gtk/nsAppShell.h | 5 --- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/toolkit/profile/nsProfileLock.cpp b/toolkit/profile/nsProfileLock.cpp index eefb66606a3c..0a809642aa62 100644 --- a/toolkit/profile/nsProfileLock.cpp +++ b/toolkit/profile/nsProfileLock.cpp @@ -115,6 +115,7 @@ static struct sigaction SIGQUIT_oldact; static struct sigaction SIGILL_oldact; static struct sigaction SIGABRT_oldact; static struct sigaction SIGSEGV_oldact; +static struct sigaction SIGTERM_oldact; void nsProfileLock::FatalSignalHandler(int signo # ifdef SA_SIGINFO @@ -147,6 +148,9 @@ void nsProfileLock::FatalSignalHandler(int signo case SIGSEGV: oldact = &SIGSEGV_oldact; break; + case SIGTERM: + oldact = &SIGTERM_oldact; + break; default: MOZ_ASSERT_UNREACHABLE("bad signo"); break; @@ -383,6 +387,7 @@ nsresult nsProfileLock::LockWithSymlink(nsIFile* aLockFile, CATCH_SIGNAL(SIGILL); CATCH_SIGNAL(SIGABRT); CATCH_SIGNAL(SIGSEGV); + CATCH_SIGNAL(SIGTERM); # undef CATCH_SIGNAL } diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp index 0062f1a5a27f..e57e43293c14 100644 --- a/widget/gtk/nsAppShell.cpp +++ b/widget/gtk/nsAppShell.cpp @@ -45,7 +45,6 @@ using mozilla::widget::ScreenHelperGTK; using mozilla::widget::ScreenManager; #define NOTIFY_TOKEN 0xFA -#define QUIT_TOKEN 0xFB LazyLogModule gWidgetLog("Widget"); LazyLogModule gWidgetDragLog("WidgetDrag"); @@ -57,8 +56,6 @@ LazyLogModule gClipboardLog("WidgetClipboard"); static GPollFunc sPollFunc; -nsAppShell* sAppShell = nullptr; - // Wrapper function to disable hang monitoring while waiting in poll(). static gint PollWrapper(GPollFD* aUfds, guint aNfsd, gint aTimeout) { if (aTimeout == 0) { @@ -145,17 +142,9 @@ gboolean nsAppShell::EventProcessorCallback(GIOChannel* source, unsigned char c; Unused << read(self->mPipeFDs[0], &c, 1); - switch (c) { - case NOTIFY_TOKEN: - self->NativeEventCallback(); - break; - case QUIT_TOKEN: - self->Exit(); - break; - default: - NS_ASSERTION(false, "wrong token"); - break; - } + NS_ASSERTION(c == (unsigned char)NOTIFY_TOKEN, "wrong token"); + + self->NativeEventCallback(); return TRUE; } @@ -301,34 +290,6 @@ void nsAppShell::StopDBusListening() { } #endif -void nsAppShell::TermSignalHandler(int signo) { - if (signo != SIGTERM) { - NS_WARNING("Wrong signal!"); - return; - } - sAppShell->ScheduleQuitEvent(); -} - -void nsAppShell::InstallTermSignalHandler() { - if (!XRE_IsParentProcess() || PR_GetEnv("MOZ_DISABLE_SIG_HANDLER")) { - return; - } - - struct sigaction act = {}, oldact; - act.sa_handler = TermSignalHandler; - sigfillset(&act.sa_mask); - - if (NS_WARN_IF(sigaction(SIGTERM, nullptr, &oldact) != 0)) { - return; - } - if (oldact.sa_handler != SIG_DFL) { - NS_WARNING("SIGTERM signal handler is already set?"); - } - - sigaction(SIGTERM, &act, nullptr); - sAppShell = this; -} - nsresult nsAppShell::Init() { mozilla::hal::Init(); @@ -452,17 +413,7 @@ void nsAppShell::ScheduleNativeEventCallback() { Unused << write(mPipeFDs[1], buf, 1); } -void nsAppShell::ScheduleQuitEvent() { - unsigned char buf[] = {QUIT_TOKEN}; - Unused << write(mPipeFDs[1], buf, 1); -} - bool nsAppShell::ProcessNextNativeEvent(bool mayWait) { - static std::once_flag onceFlag; - std::call_once(onceFlag, [self = MOZ_KnownLive(this)] { - self->InstallTermSignalHandler(); - }); - if (mSuspendNativeCount) { return false; } diff --git a/widget/gtk/nsAppShell.h b/widget/gtk/nsAppShell.h index 9837121a5e2b..f907fff7bae3 100644 --- a/widget/gtk/nsAppShell.h +++ b/widget/gtk/nsAppShell.h @@ -48,11 +48,6 @@ class nsAppShell : public nsBaseAppShell { static gboolean EventProcessorCallback(GIOChannel* source, GIOCondition condition, gpointer data); - void InstallTermSignalHandler(); - static void TermSignalHandler(int signo); - - void ScheduleQuitEvent(); - int mPipeFDs[2]; unsigned mTag;