| 219 | } |
| 220 | |
| 221 | HANDLE InputManager::AcquireMutex() { |
| 222 | HANDLE mutex_handle = ::CreateMutex(NULL, FALSE, USER_INTERACTION_MUTEX_NAME); |
| 223 | if (mutex_handle != NULL) { |
| 224 | // Wait for up to the timeout (currently 30 seconds) for the mutex to be |
| 225 | // released. |
| 226 | DWORD mutex_wait_status = ::WaitForSingleObject(mutex_handle, 30000); |
| 227 | if (mutex_wait_status == WAIT_ABANDONED) { |
| 228 | LOG(WARN) << "Acquired mutex, but received wait abandoned status. This " |
| 229 | << "could mean the process previously owning the mutex was " |
| 230 | << "unexpectedly terminated."; |
| 231 | } |
| 232 | else if (mutex_wait_status == WAIT_TIMEOUT) { |
| 233 | LOG(WARN) << "Could not acquire mutex within the timeout. Multiple " |
| 234 | << "instances may have incorrect synchronization for interactions"; |
| 235 | } |
| 236 | else if (mutex_wait_status == WAIT_OBJECT_0) { |
| 237 | LOG(DEBUG) << "Mutex acquired for user interaction."; |
| 238 | } |
| 239 | } |
| 240 | else { |
| 241 | LOG(WARN) << "Could not create user interaction mutex. Multiple " |
| 242 | << "instances of IE may behave unpredictably."; |
| 243 | } |
| 244 | return mutex_handle; |
| 245 | } |
| 246 | |
| 247 | void InputManager::ReleaseMutex(HANDLE mutex_handle) { |
| 248 | if (mutex_handle != NULL) { |
no test coverage detected