Commit c731edae authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

Converting DPLOGs to PLOGs for better service install diagnostics.

Also added a log statement and a cleanup of a value in the unit test.

Bug: 1058506
Change-Id: I6e43df059f11d7fdba8c430458a1d1f298a56905
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090916
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Auto-Submit: S. Ganesh <ganesh@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747927}
parent 48eaa20b
...@@ -148,7 +148,8 @@ bool InstallServiceWorkItemImpl::DoImpl() { ...@@ -148,7 +148,8 @@ bool InstallServiceWorkItemImpl::DoImpl() {
return succeeded; return succeeded;
} }
PLOG(ERROR) << "Failed to install service"; PLOG(ERROR) << "Failed to install service "
<< GetCurrentServiceName().c_str();
RecordServiceInstallResult(ServiceInstallResult::kFailedFreshInstall); RecordServiceInstallResult(ServiceInstallResult::kFailedFreshInstall);
RecordWin32ApiErrorCode(kCreateService); RecordWin32ApiErrorCode(kCreateService);
// Fall through to try installing the service by generating a new name. // Fall through to try installing the service by generating a new name.
...@@ -158,6 +159,9 @@ bool InstallServiceWorkItemImpl::DoImpl() { ...@@ -158,6 +159,9 @@ bool InstallServiceWorkItemImpl::DoImpl() {
// likely to fail. Less intrusive to the SCM and to AV/Anti-malware // likely to fail. Less intrusive to the SCM and to AV/Anti-malware
// programs. // programs.
return true; return true;
} else {
LOG(ERROR) << "Failed to upgrade service "
<< GetCurrentServiceName().c_str();
} }
// Save the original service name. Then create a new service name so as to not // Save the original service name. Then create a new service name so as to not
...@@ -183,7 +187,8 @@ bool InstallServiceWorkItemImpl::DoImpl() { ...@@ -183,7 +187,8 @@ bool InstallServiceWorkItemImpl::DoImpl() {
return true; return true;
} }
PLOG(ERROR) << "Failed to install service with new name"; PLOG(ERROR) << "Failed to install service with new name "
<< GetCurrentServiceName().c_str();
RecordServiceInstallResult( RecordServiceInstallResult(
ServiceInstallResult::kFailedInstallNewAfterFailedUpgrade); ServiceInstallResult::kFailedInstallNewAfterFailedUpgrade);
RecordWin32ApiErrorCode(kCreateService); RecordWin32ApiErrorCode(kCreateService);
...@@ -307,7 +312,8 @@ bool InstallServiceWorkItemImpl::GetServiceConfig(ServiceConfig* config) const { ...@@ -307,7 +312,8 @@ bool InstallServiceWorkItemImpl::GetServiceConfig(ServiceConfig* config) const {
if (!::QueryServiceConfig(service_.Get(), service_config, if (!::QueryServiceConfig(service_.Get(), service_config,
kMaxQueryConfigBufferBytes, kMaxQueryConfigBufferBytes,
&bytes_needed_ignored)) { &bytes_needed_ignored)) {
DPLOG(ERROR) << "QueryServiceConfig failed"; PLOG(ERROR) << "QueryServiceConfig failed "
<< GetCurrentServiceName().c_str();
return false; return false;
} }
...@@ -340,14 +346,14 @@ bool InstallServiceWorkItemImpl::SetServiceName( ...@@ -340,14 +346,14 @@ bool InstallServiceWorkItemImpl::SetServiceName(
KEY_SET_VALUE | KEY_WOW64_32KEY); KEY_SET_VALUE | KEY_WOW64_32KEY);
if (result != ERROR_SUCCESS) { if (result != ERROR_SUCCESS) {
::SetLastError(result); ::SetLastError(result);
DPLOG(ERROR) << "key.Create failed"; PLOG(ERROR) << "key.Create failed";
return false; return false;
} }
result = key.WriteValue(service_name_.c_str(), service_name.c_str()); result = key.WriteValue(service_name_.c_str(), service_name.c_str());
if (result != ERROR_SUCCESS) { if (result != ERROR_SUCCESS) {
::SetLastError(result); ::SetLastError(result);
DPLOG(ERROR) << "key.WriteValue failed"; PLOG(ERROR) << "key.WriteValue failed";
return false; return false;
} }
...@@ -450,7 +456,8 @@ bool InstallServiceWorkItemImpl::InstallService(const ServiceConfig& config) { ...@@ -450,7 +456,8 @@ bool InstallServiceWorkItemImpl::InstallService(const ServiceConfig& config) {
!config.dependencies.empty() ? config.dependencies.data() : nullptr, !config.dependencies.empty() ? config.dependencies.data() : nullptr,
nullptr, nullptr)); nullptr, nullptr));
if (!service.IsValid()) { if (!service.IsValid()) {
DPLOG(WARNING) << "Failed to create service"; PLOG(WARNING) << "Failed to create service "
<< GetCurrentServiceName().c_str();
return false; return false;
} }
...@@ -468,7 +475,8 @@ bool InstallServiceWorkItemImpl::ChangeServiceConfig( ...@@ -468,7 +475,8 @@ bool InstallServiceWorkItemImpl::ChangeServiceConfig(
config.cmd_line.c_str(), nullptr, nullptr, config.cmd_line.c_str(), nullptr, nullptr,
!config.dependencies.empty() ? config.dependencies.data() : nullptr, !config.dependencies.empty() ? config.dependencies.data() : nullptr,
nullptr, nullptr, nullptr)) { nullptr, nullptr, nullptr)) {
DPLOG(WARNING) << "Failed to change service config"; PLOG(WARNING) << "Failed to change service config "
<< GetCurrentServiceName().c_str();
return false; return false;
} }
...@@ -481,7 +489,7 @@ bool InstallServiceWorkItemImpl::DeleteService(ScopedScHandle service) const { ...@@ -481,7 +489,7 @@ bool InstallServiceWorkItemImpl::DeleteService(ScopedScHandle service) const {
if (!::DeleteService(service.Get())) { if (!::DeleteService(service.Get())) {
DWORD error = ::GetLastError(); DWORD error = ::GetLastError();
DPLOG(WARNING) << "DeleteService failed"; PLOG(WARNING) << "DeleteService failed " << GetCurrentServiceName().c_str();
return error == ERROR_SERVICE_MARKED_FOR_DELETE; return error == ERROR_SERVICE_MARKED_FOR_DELETE;
} }
......
...@@ -139,6 +139,7 @@ TEST_F(InstallServiceWorkItemTest, Do_ServiceName) { ...@@ -139,6 +139,7 @@ TEST_F(InstallServiceWorkItemTest, Do_ServiceName) {
key.Create(HKEY_LOCAL_MACHINE, key.Create(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(), install_static::GetClientStateKeyPath().c_str(),
KEY_WRITE | KEY_WOW64_32KEY)); KEY_WRITE | KEY_WOW64_32KEY));
key.DeleteValue(kServiceName);
auto item = std::make_unique<InstallServiceWorkItem>( auto item = std::make_unique<InstallServiceWorkItem>(
kServiceName, kServiceDisplayName, kServiceName, kServiceDisplayName,
base::CommandLine(base::FilePath(kServiceProgramPath))); base::CommandLine(base::FilePath(kServiceProgramPath)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment