Chromium Code Reviews| Index: chrome/browser/process_singleton_posix.cc |
| diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc |
| index f8786c67e6404c2678b65f8c0b16da815ce02d74..72282f631fdc4d0bfe8e5e8a26f566fb0f321c73 100644 |
| --- a/chrome/browser/process_singleton_posix.cc |
| +++ b/chrome/browser/process_singleton_posix.cc |
| @@ -776,6 +776,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| if (hostname.empty()) { |
| // Invalid lockfile. |
| UnlinkPath(lock_path_); |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + INVALID_LOCK_FILE, MAX_HUNG_REMOTE_PROCESS_ACTION); |
|
gab
2017/05/10 15:16:50
Each UMA macro expands to a fair amount of code. E
Alexey Seren
2017/05/11 13:42:05
Acknowledged.
|
| return PROCESS_NONE; |
| } |
| @@ -784,6 +787,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| // the profile, try to continue; otherwise quit. |
| if (DisplayProfileInUseError(lock_path_, hostname, pid)) { |
| UnlinkPath(lock_path_); |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + PROFILE_UNLOCKED, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| return PROCESS_NONE; |
| } |
| return PROFILE_IN_USE; |
| @@ -791,6 +797,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| if (!IsChromeProcess(pid)) { |
| // Orphaned lockfile (no process with pid, or non-chrome process.) |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + ORPHANED_LOCK_FILE, MAX_HUNG_REMOTE_PROCESS_ACTION); |
|
gab
2017/05/10 15:16:50
To be consistent I'd say have the UMA logging alwa
Alexey Seren
2017/05/11 13:42:05
Acknowledged.
|
| UnlinkPath(lock_path_); |
| return PROCESS_NONE; |
| } |
| @@ -799,10 +808,18 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| // Orphaned lockfile (pid is part of same chrome instance we are, even |
| // though we haven't tried to create a lockfile yet). |
| UnlinkPath(lock_path_); |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + SAME_BROWSER_INSTANCE, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| return PROCESS_NONE; |
| } |
| if (retries == retry_attempts) { |
| + if (kill_unresponsive) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteHungProcessTerminateReason", |
| + NOTIFY_ATTEMPTS_EXCEEDED, MAX_REMOTE_HUNG_PROCESS_TERMINATE_REASON); |
|
gab
2017/05/10 15:16:50
Same here, instead of if (kill_unresponsive) {}, m
Alexey Seren
2017/05/11 13:42:05
Acknowledged.
|
| + } |
| // Retries failed. Kill the unresponsive chrome process and continue. |
| if (!kill_unresponsive || !KillProcessByLockPath()) |
| return PROFILE_IN_USE; |
| @@ -838,6 +855,11 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| // Send the message |
| if (!WriteToSocket(socket.fd(), to_send.data(), to_send.length())) { |
| + if (kill_unresponsive) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteHungProcessTerminateReason", |
| + SOCKET_WRITE_FAILED, MAX_REMOTE_HUNG_PROCESS_TERMINATE_REASON); |
| + } |
| // Try to kill the other process, because it might have been dead. |
| if (!kill_unresponsive || !KillProcessByLockPath()) |
| return PROFILE_IN_USE; |
| @@ -854,6 +876,11 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| // Failed to read ACK, the other process might have been frozen. |
| if (len <= 0) { |
| + if (kill_unresponsive) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteHungProcessTerminateReason", |
| + SOCKET_READ_FAILED, MAX_REMOTE_HUNG_PROCESS_TERMINATE_REASON); |
| + } |
| if (!kill_unresponsive || !KillProcessByLockPath()) |
| return PROFILE_IN_USE; |
| return PROCESS_NONE; |
| @@ -862,6 +889,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout( |
| buf[len] = '\0'; |
| if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) { |
| // The other process is shutting down, it's safe to start a new process. |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + REMOTE_PROCESS_SHUTTING_DOWN, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| return PROCESS_NONE; |
| } else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) { |
| #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| @@ -1057,18 +1087,33 @@ bool ProcessSingleton::KillProcessByLockPath() { |
| ParseLockPath(lock_path_, &hostname, &pid); |
| if (!hostname.empty() && hostname != net::GetHostName()) { |
| - return DisplayProfileInUseError(lock_path_, hostname, pid); |
| + bool res = DisplayProfileInUseError(lock_path_, hostname, pid); |
| + if (res) { |
| + UnlinkPath(lock_path_); |
|
Alexey Seren
2017/05/10 04:27:07
We need to unlink lock file if user selects to unl
gab
2017/05/10 15:16:50
Is this a bug fix? If so, should go in a separate
Alexey Seren
2017/05/11 13:42:05
Yes it is a bug fix. I will move it to separate CL
|
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + PROFILE_UNLOCKED, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| + } |
| + return res; |
| } |
| UnlinkPath(lock_path_); |
| - if (IsSameChromeInstance(pid)) |
| + if (IsSameChromeInstance(pid)) { |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + SAME_BROWSER_INSTANCE, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| return true; |
| + } |
| if (pid > 0) { |
| kill_callback_.Run(pid); |
| return true; |
| } |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", |
| + FAILED_TO_EXTRACT_PID, MAX_HUNG_REMOTE_PROCESS_ACTION); |
| + |
| LOG(ERROR) << "Failed to extract pid from path: " << lock_path_.value(); |
| return true; |
| } |
| @@ -1080,4 +1125,24 @@ void ProcessSingleton::KillProcess(int pid) { |
| // progress of shutting down and finishes before we try to kill it). |
| DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " |
| << base::safe_strerror(errno); |
| + |
| + int error_code = (rv == 0) ? 0 : errno; |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Chrome.ProcessSingleton.TerminateProcessErrorCode.Posix", error_code); |
| + |
| + RemoteProcessInteractionResult action = TERMINATE_SUCCEEDED; |
| + if (rv != 0) { |
| + switch (error_code) { |
| + case ESRCH: |
| + action = REMOTE_PROCESS_NOT_FOUND; |
| + break; |
| + case EPERM: |
| + action = TERMINATE_NOT_ENOUGH_PERMISSIONS; |
| + break; |
| + default: { action = TERMINATE_FAILED; } |
|
gab
2017/05/10 15:16:50
use same syntax as other cases for default, i.e.
Alexey Seren
2017/05/11 13:42:05
Acknowledged.
|
| + } |
| + } |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "Chrome.ProcessSingleton.RemoteProcessInteractionResult", action, |
| + MAX_HUNG_REMOTE_PROCESS_ACTION); |
| } |