Always initialize Trace in Call TraceDispatcher.
Prevents violation of lock order occuring previously when RegisterCallback called SetTraceCallback while holding its lock, which called Print back (which acquires the lock). BUG= R=andrew@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7559004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5433 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
37c2976511
commit
c98882dcd3
@ -91,21 +91,22 @@ class Call : public webrtc::Call, public PacketReceiver {
|
||||
class TraceDispatcher : public TraceCallback {
|
||||
public:
|
||||
TraceDispatcher()
|
||||
: crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
initialized_(false),
|
||||
filter_(kTraceNone) {}
|
||||
: lock_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
filter_(kTraceNone) {
|
||||
Trace::CreateTrace();
|
||||
VideoEngine::SetTraceCallback(this);
|
||||
VideoEngine::SetTraceFilter(kTraceNone);
|
||||
}
|
||||
|
||||
~TraceDispatcher() {
|
||||
if (initialized_) {
|
||||
Trace::ReturnTrace();
|
||||
VideoEngine::SetTraceCallback(NULL);
|
||||
}
|
||||
Trace::ReturnTrace();
|
||||
VideoEngine::SetTraceCallback(NULL);
|
||||
}
|
||||
|
||||
virtual void Print(TraceLevel level,
|
||||
const char* message,
|
||||
int length) OVERRIDE {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
CriticalSectionScoped crit(lock_.get());
|
||||
for (std::map<Call*, Call::Config*>::iterator it = callbacks_.begin();
|
||||
it != callbacks_.end();
|
||||
++it) {
|
||||
@ -118,20 +119,15 @@ class TraceDispatcher : public TraceCallback {
|
||||
if (config->trace_callback == NULL)
|
||||
return;
|
||||
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
CriticalSectionScoped crit(lock_.get());
|
||||
callbacks_[call] = config;
|
||||
|
||||
filter_ |= config->trace_filter;
|
||||
if (filter_ != kTraceNone && !initialized_) {
|
||||
initialized_ = true;
|
||||
Trace::CreateTrace();
|
||||
VideoEngine::SetTraceCallback(this);
|
||||
}
|
||||
VideoEngine::SetTraceFilter(filter_);
|
||||
}
|
||||
|
||||
void DeregisterCallback(Call* call) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
CriticalSectionScoped crit(lock_.get());
|
||||
callbacks_.erase(call);
|
||||
|
||||
filter_ = kTraceNone;
|
||||
@ -145,8 +141,7 @@ class TraceDispatcher : public TraceCallback {
|
||||
}
|
||||
|
||||
private:
|
||||
scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
bool initialized_;
|
||||
scoped_ptr<CriticalSectionWrapper> lock_;
|
||||
unsigned int filter_;
|
||||
std::map<Call*, Call::Config*> callbacks_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user