Bug 716126 - Include update.status contents inside maintenanceservice.log file on failed updates. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Tue, 10 Jan 2012 11:28:50 -0500
changeset 85355 5060dad145fd1ba698f4cf738faa77a9e95ef77a
parent 85354 4f2f486f898f4954b3df7c224b232b70e541828f
child 85356 1b76dd555ee7d5cdcbaf6e5b811c44a3a9f5af4a
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs716126
milestone12.0a1
Bug 716126 - Include update.status contents inside maintenanceservice.log file on failed updates. r=rstrong
toolkit/components/maintenanceservice/maintenanceservice.cpp
toolkit/components/maintenanceservice/servicebase.cpp
toolkit/components/maintenanceservice/workmonitor.cpp
--- a/toolkit/components/maintenanceservice/maintenanceservice.cpp
+++ b/toolkit/components/maintenanceservice/maintenanceservice.cpp
@@ -49,18 +49,18 @@
 #include "updatehelper.h"
 
 SERVICE_STATUS gSvcStatus = { 0 }; 
 SERVICE_STATUS_HANDLE gSvcStatusHandle = NULL; 
 HANDLE gWorkDoneEvent = NULL;
 HANDLE gThread = NULL;
 bool gServiceControlStopping = false;
 
-// logs are pretty small ~10 lines, so 5 seems reasonable.
-#define LOGS_TO_KEEP 5
+// logs are pretty small, about 20 lines, so 10 seems reasonable.
+#define LOGS_TO_KEEP 10
 
 BOOL GetLogDirectoryPath(WCHAR *path);
 
 int 
 wmain(int argc, WCHAR **argv)
 {
   // If command-line parameter is "install", install the service
   // or upgrade if already installed
--- a/toolkit/components/maintenanceservice/servicebase.cpp
+++ b/toolkit/components/maintenanceservice/servicebase.cpp
@@ -50,22 +50,22 @@
  * @return TRUE If there was no error checking the files.
  */
 BOOL
 VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
 {
   sameContent = FALSE;
   nsAutoHandle file1(CreateFileW(file1Path, GENERIC_READ, FILE_SHARE_READ, 
                                  NULL, OPEN_EXISTING, 0, NULL));
-  if (!file1) {
+  if (INVALID_HANDLE_VALUE == file1) {
     return FALSE;
   }
   nsAutoHandle file2(CreateFileW(file2Path, GENERIC_READ, FILE_SHARE_READ, 
                                  NULL, OPEN_EXISTING, 0, NULL));
-  if (!file2) {
+  if (INVALID_HANDLE_VALUE == file2) {
     return FALSE;
   }
 
   DWORD fileSize1 = GetFileSize(file1, NULL);
   DWORD fileSize2 = GetFileSize(file2, NULL);
   if (INVALID_FILE_SIZE == fileSize1 || INVALID_FILE_SIZE == fileSize2) {
     return FALSE;
   }
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -87,30 +87,40 @@ const int SERVICE_STILL_APPLYING_ON_FAIL
 */
 static BOOL
 IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying)
 {
   isApplying = FALSE;
   WCHAR updateStatusFilePath[MAX_PATH + 1];
   wcscpy(updateStatusFilePath, updateDirPath);
   if (!PathAppendSafe(updateStatusFilePath, L"update.status")) {
+    LOG(("Warning: Could not append path for update.status file\n"));
     return FALSE;
   }
 
   nsAutoHandle statusFile(CreateFileW(updateStatusFilePath, GENERIC_READ,
                                       FILE_SHARE_READ | 
                                       FILE_SHARE_WRITE | 
                                       FILE_SHARE_DELETE,
                                       NULL, OPEN_EXISTING, 0, NULL));
+
+  if (INVALID_HANDLE_VALUE == statusFile) {
+    LOG(("Warning: Could not open update.status file\n"));
+    return FALSE;
+  }
+
   char buf[32] = { 0 };
   DWORD read;
   if (!ReadFile(statusFile, buf, sizeof(buf), &read, NULL)) {
+    LOG(("Warning: Could not read from update.status file\n"));
     return FALSE;
   }
 
+  LOG(("updater.exe returned status: %s\n", buf));
+
   const char kApplying[] = "applying";
   isApplying = strncmp(buf, kApplying, 
                        sizeof(kApplying) - 1) == 0;
   return TRUE;
 }
 
 
 /**