Bug 1463560: Part 1: Re-add the -os-restarted arg when launching after an update. r=mhowell
authorAdam Gashlin <agashlin@mozilla.com>
Sun, 27 May 2018 12:22:05 -0700
changeset 475721 d6ab9a83f57ce7664410de28a412df6eb2f24443
parent 475720 bb7dec4331c1021f37d1e4d2b81571c8391ca0f9
child 475722 06d152dae420825cfd78edf3fc094cdd16434945
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1463560
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463560: Part 1: Re-add the -os-restarted arg when launching after an update. r=mhowell MozReview-Commit-ID: 509GetTCBCF
toolkit/xre/nsAppRunner.h
toolkit/xre/nsUpdateDriver.cpp
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -40,16 +40,17 @@ extern nsXREDirProvider* gDirServiceProv
 // NOTE: gAppData will be null in embedded contexts.
 extern const mozilla::XREAppData* gAppData;
 extern bool gSafeMode;
 
 extern int    gArgc;
 extern char **gArgv;
 extern int    gRestartArgc;
 extern char **gRestartArgv;
+extern bool gRestartedByOS;
 extern bool gLogConsoleErrors;
 extern nsString gAbsoluteArgv0Path;
 
 extern bool gIsGtest;
 
 /**
  * Create the nativeappsupport implementation.
  *
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -601,36 +601,42 @@ ApplyUpdate(nsIFile *greDir, nsIFile *up
   } else {
     // Signal the updater application that it should stage the update.
     pid.AssignASCII("-1");
   }
 
   int argc = 5;
   if (restart) {
     argc = appArgc + 6;
+    if (gRestartedByOS) {
+      argc += 1;
+    }
   }
   char **argv = new char*[argc + 1];
   if (!argv) {
     return;
   }
   argv[0] = (char*) updaterPath.get();
   argv[1] = (char*) updateDirPath.get();
   argv[2] = (char*) installDirPath.get();
   argv[3] = (char*) applyToDirPath.get();
   argv[4] = (char*) pid.get();
   if (restart && appArgc) {
     argv[5] = workingDirPath;
     argv[6] = (char*) appFilePath.get();
     for (int i = 1; i < appArgc; ++i) {
       argv[6 + i] = appArgv[i];
     }
-    argv[argc] = nullptr;
-  } else {
-    argv[5] = nullptr;
+    if (gRestartedByOS) {
+      // We haven't truly started up, restore this argument so that we will have
+      // it upon restart.
+      argv[6 + appArgc] = const_cast<char*>("-os-restarted");
+    }
   }
+  argv[argc] = nullptr;
 
   if (restart && gSafeMode) {
     PR_SetEnv("MOZ_SAFE_MODE_RESTART=1");
   }
 
 #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && !defined(XP_MACOSX)
   AppendToLibPath(installDirPath.get());
 #endif