Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: base/logging.cc

Issue 159723: Do not abort the process if thread owning the log mutex has crashed. (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 typedef HANDLE FileHandle; 9 typedef HANDLE FileHandle;
10 typedef HANDLE MutexHandle; 10 typedef HANDLE MutexHandle;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 InitializeLogFileHandle()) { 478 InitializeLogFileHandle()) {
479 // We can have multiple threads and/or processes, so try to prevent them 479 // We can have multiple threads and/or processes, so try to prevent them
480 // from clobbering each other's writes. 480 // from clobbering each other's writes.
481 if (lock_log_file == LOCK_LOG_FILE) { 481 if (lock_log_file == LOCK_LOG_FILE) {
482 // Ensure that the mutex is initialized in case the client app did not 482 // Ensure that the mutex is initialized in case the client app did not
483 // call InitLogging. This is not thread safe. See below. 483 // call InitLogging. This is not thread safe. See below.
484 InitLogMutex(); 484 InitLogMutex();
485 485
486 #if defined(OS_WIN) 486 #if defined(OS_WIN)
487 DWORD r = ::WaitForSingleObject(log_mutex, INFINITE); 487 DWORD r = ::WaitForSingleObject(log_mutex, INFINITE);
488 DCHECK(r != WAIT_ABANDONED); 488 if (r == WAIT_ABANDONED) {
489 // Do not abort the process here. UI tests might be crashy sometimes,
490 // and aborting the test binary only makes the problem worse.
491 // For more info see http://crbug.com/18028.
492 LOG(ERROR) << "Thread owning the log mutex has crashed.";
cpu_(ooo_6.6-7.5) 2009/07/31 23:04:05 hmmm ... you are calling LOG()which ends up back h
493 }
489 #elif defined(OS_POSIX) 494 #elif defined(OS_POSIX)
490 pthread_mutex_lock(&log_mutex); 495 pthread_mutex_lock(&log_mutex);
491 #endif 496 #endif
492 } else { 497 } else {
493 // use the lock 498 // use the lock
494 if (!log_lock) { 499 if (!log_lock) {
495 // The client app did not call InitLogging, and so the lock has not 500 // The client app did not call InitLogging, and so the lock has not
496 // been created. We do this on demand, but if two threads try to do 501 // been created. We do this on demand, but if two threads try to do
497 // this at the same time, there will be a race condition to create 502 // this at the same time, there will be a race condition to create
498 // the lock. This is why InitLogging should be called from the main 503 // the lock. This is why InitLogging should be called from the main
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 574
570 CloseFile(log_file); 575 CloseFile(log_file);
571 log_file = NULL; 576 log_file = NULL;
572 } 577 }
573 578
574 } // namespace logging 579 } // namespace logging
575 580
576 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { 581 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) {
577 return out << base::SysWideToUTF8(std::wstring(wstr)); 582 return out << base::SysWideToUTF8(std::wstring(wstr));
578 } 583 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698