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

Unified Diff: webrtc/base/messagequeue.h

Issue 1675923002: Prevent data race in MessageQueue. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed initialization order. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/messagequeue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/messagequeue.h
diff --git a/webrtc/base/messagequeue.h b/webrtc/base/messagequeue.h
index a7991a8923ad407c216c63542445077df50d2896..efc479cf2644243d8abff92dcfe414e43055d97b 100644
--- a/webrtc/base/messagequeue.h
+++ b/webrtc/base/messagequeue.h
@@ -24,9 +24,11 @@
#include "webrtc/base/messagehandler.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/scoped_ref_ptr.h"
+#include "webrtc/base/sharedexclusivelock.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/socketserver.h"
#include "webrtc/base/timeutils.h"
+#include "webrtc/base/thread_annotations.h"
namespace rtc {
@@ -181,7 +183,7 @@ class MessageQueue {
// calling Clear on the object from a different thread.
virtual ~MessageQueue();
- SocketServer* socketserver() { return ss_; }
+ SocketServer* socketserver();
void set_socketserver(SocketServer* ss);
// Note: The behavior of MessageQueue has changed. When a MQ is stopped,
@@ -260,21 +262,25 @@ class MessageQueue {
// destructor.
void DoDestroy();
- // The SocketServer is not owned by MessageQueue.
- SocketServer* ss_;
- // If a server isn't supplied in the constructor, use this one.
- scoped_ptr<SocketServer> default_ss_;
+ void WakeUpSocketServer();
+
bool fStop_;
bool fPeekKeep_;
Message msgPeek_;
- MessageList msgq_;
- PriorityQueue dmsgq_;
- uint32_t dmsgq_next_num_;
+ MessageList msgq_ GUARDED_BY(crit_);
+ PriorityQueue dmsgq_ GUARDED_BY(crit_);
+ uint32_t dmsgq_next_num_ GUARDED_BY(crit_);
CriticalSection crit_;
bool fInitialized_;
bool fDestroyed_;
private:
+ // The SocketServer is not owned by MessageQueue.
+ SocketServer* ss_ GUARDED_BY(ss_lock_);
+ // If a server isn't supplied in the constructor, use this one.
+ scoped_ptr<SocketServer> default_ss_;
+ SharedExclusiveLock ss_lock_;
+
RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue);
};
« no previous file with comments | « no previous file | webrtc/base/messagequeue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698