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

Side by Side Diff: base/synchronization/condition_variable_posix.cc

Issue 1323293005: mac: Add a hack to condition_variable_posix.cc to avoid a crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/synchronization/condition_variable.h" 5 #include "base/synchronization/condition_variable.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/time.h> 8 #include <sys/time.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC); 35 pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC);
36 rv = pthread_cond_init(&condition_, &attrs); 36 rv = pthread_cond_init(&condition_, &attrs);
37 pthread_condattr_destroy(&attrs); 37 pthread_condattr_destroy(&attrs);
38 #else 38 #else
39 rv = pthread_cond_init(&condition_, NULL); 39 rv = pthread_cond_init(&condition_, NULL);
40 #endif 40 #endif
41 DCHECK_EQ(0, rv); 41 DCHECK_EQ(0, rv);
42 } 42 }
43 43
44 ConditionVariable::~ConditionVariable() { 44 ConditionVariable::~ConditionVariable() {
45 #if defined(OS_MACOSX)
46 // This hack is necessary to avoid a fatal pthreads subsystem bug in the
47 // Darwin kernel. http://crbug.com/517681.
48 {
Mark Mentovai 2015/09/04 12:30:56 The bug says 10.10 and 10.11. Does this happen on
erikchen 2015/09/04 17:25:37 It does - the comment was looking only at the most
49 base::Lock lock;
Mark Mentovai 2015/09/04 12:30:56 How do we know that the memory used for this mutex
erikchen 2015/09/04 17:25:37 We could, soon after each new thread is created, m
50 base::AutoLock l(lock);
51 struct timespec ts;
52 ts.tv_sec = 0;
53 ts.tv_nsec = 1;
54 pthread_cond_timedwait_relative_np(&condition_, lock.lock_.native_handle(),
55 &ts);
56 }
57 #endif
58
45 int rv = pthread_cond_destroy(&condition_); 59 int rv = pthread_cond_destroy(&condition_);
46 DCHECK_EQ(0, rv); 60 DCHECK_EQ(0, rv);
47 } 61 }
48 62
49 void ConditionVariable::Wait() { 63 void ConditionVariable::Wait() {
50 base::ThreadRestrictions::AssertWaitAllowed(); 64 base::ThreadRestrictions::AssertWaitAllowed();
51 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 65 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
52 user_lock_->CheckHeldAndUnmark(); 66 user_lock_->CheckHeldAndUnmark();
53 #endif 67 #endif
54 int rv = pthread_cond_wait(&condition_, user_mutex_); 68 int rv = pthread_cond_wait(&condition_, user_mutex_);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 int rv = pthread_cond_broadcast(&condition_); 127 int rv = pthread_cond_broadcast(&condition_);
114 DCHECK_EQ(0, rv); 128 DCHECK_EQ(0, rv);
115 } 129 }
116 130
117 void ConditionVariable::Signal() { 131 void ConditionVariable::Signal() {
118 int rv = pthread_cond_signal(&condition_); 132 int rv = pthread_cond_signal(&condition_);
119 DCHECK_EQ(0, rv); 133 DCHECK_EQ(0, rv);
120 } 134 }
121 135
122 } // namespace base 136 } // namespace base
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