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

Unified Diff: webrtc/base/messagequeue.cc

Issue 2023193002: Protect MessageQueue stop field with a critical section to avoid data races. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Clear suppresion is needed for vtable/destructor race Created 4 years, 5 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 | « webrtc/base/messagequeue.h ('k') | webrtc/base/thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/messagequeue.cc
diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc
index c407870e6a2a01f0cc88a559989ebc2aecc53b1e..0744223e937abd4716429d89ccf5911f130146ed 100644
--- a/webrtc/base/messagequeue.cc
+++ b/webrtc/base/messagequeue.cc
@@ -141,8 +141,12 @@ void MessageQueueManager::ProcessAllMessageQueuesInternal() {
//------------------------------------------------------------------
// MessageQueue
MessageQueue::MessageQueue(SocketServer* ss, bool init_queue)
- : fStop_(false), fPeekKeep_(false),
- dmsgq_next_num_(0), fInitialized_(false), fDestroyed_(false), ss_(ss) {
+ : fPeekKeep_(false),
+ dmsgq_next_num_(0),
+ fInitialized_(false),
+ fDestroyed_(false),
+ stop_(false),
Taylor Brandstetter 2016/07/07 22:01:47 Since it's an int now, should probably initialize
andresp 2016/07/08 10:05:37 Done.
+ ss_(ss) {
RTC_DCHECK(ss);
// Currently, MessageQueue holds a socket server, and is the base class for
// Thread. It seems like it makes more sense for Thread to hold the socket
@@ -214,16 +218,16 @@ void MessageQueue::WakeUpSocketServer() {
}
void MessageQueue::Quit() {
- fStop_ = true;
+ AtomicOps::ReleaseStore(&stop_, 1);
WakeUpSocketServer();
}
bool MessageQueue::IsQuitting() {
- return fStop_;
+ return AtomicOps::AcquireLoad(&stop_) != 0;
}
void MessageQueue::Restart() {
- fStop_ = false;
+ AtomicOps::ReleaseStore(&stop_, 0);
}
bool MessageQueue::Peek(Message *pmsg, int cmsWait) {
@@ -307,7 +311,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
return true;
}
- if (fStop_)
+ if (IsQuitting())
break;
// Which is shorter, the delay wait or the asked wait?
@@ -348,7 +352,7 @@ void MessageQueue::Post(const Location& posted_from,
uint32_t id,
MessageData* pdata,
bool time_sensitive) {
- if (fStop_)
+ if (IsQuitting())
return;
// Keep thread safe
@@ -404,7 +408,7 @@ void MessageQueue::DoDelayPost(const Location& posted_from,
MessageHandler* phandler,
uint32_t id,
MessageData* pdata) {
- if (fStop_) {
+ if (IsQuitting()) {
return;
}
« no previous file with comments | « webrtc/base/messagequeue.h ('k') | webrtc/base/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698