From 38d23b0c2b25c5eeee36a489178c8e4f874edd8c Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Tue, 10 Jan 2012 11:28:50 -0500 Subject: [PATCH] Bug 716126 - Include update.status contents inside maintenanceservice.log file on failed updates. r=rstrong --- .../maintenanceservice/maintenanceservice.cpp | 4 ++-- toolkit/components/maintenanceservice/servicebase.cpp | 4 ++-- toolkit/components/maintenanceservice/workmonitor.cpp | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/toolkit/components/maintenanceservice/maintenanceservice.cpp b/toolkit/components/maintenanceservice/maintenanceservice.cpp index 31a5af74bd1..d0583444541 100644 --- a/toolkit/components/maintenanceservice/maintenanceservice.cpp +++ b/toolkit/components/maintenanceservice/maintenanceservice.cpp @@ -54,8 +54,8 @@ 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); diff --git a/toolkit/components/maintenanceservice/servicebase.cpp b/toolkit/components/maintenanceservice/servicebase.cpp index dbe0e87cea5..ccff9f9e9c5 100644 --- a/toolkit/components/maintenanceservice/servicebase.cpp +++ b/toolkit/components/maintenanceservice/servicebase.cpp @@ -55,12 +55,12 @@ 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; } diff --git a/toolkit/components/maintenanceservice/workmonitor.cpp b/toolkit/components/maintenanceservice/workmonitor.cpp index 8c06f9aca2a..6168ff64ec0 100644 --- a/toolkit/components/maintenanceservice/workmonitor.cpp +++ b/toolkit/components/maintenanceservice/workmonitor.cpp @@ -92,6 +92,7 @@ IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying) 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; } @@ -100,12 +101,21 @@ IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying) 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;