Bug 1713294 - Use atomics for Unsound_IsClosed and Unsound_NumQueuedMessages, r=ipc-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D117039
This commit is contained in:
Nika Layzell 2021-06-07 22:00:35 +00:00
parent bb1ab4b1d3
commit d3e5a4039d
2 changed files with 6 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include <sys/socket.h> // for CMSG macros
#include <atomic>
#include <string>
#include <vector>
#include <list>
@ -139,7 +140,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
bool processing_incoming_;
// This flag is set after we've closed the channel.
bool closed_;
std::atomic<bool> closed_;
// We keep track of the PID of the other side of this channel so that we can
// record this when generating logs of IPC messages.
@ -165,7 +166,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
// read output_queue_length_ from any thread (if we're OK getting an
// occasional out-of-date or bogus value). We use output_queue_length_ to
// implement Unsound_NumQueuedMessages.
size_t output_queue_length_;
std::atomic<size_t> output_queue_length_;
ScopedRunnableMethodFactory<ChannelImpl> factory_;

View File

@ -10,6 +10,7 @@
#include "chrome/common/ipc_channel.h"
#include "chrome/common/ipc_message.h"
#include <atomic>
#include <string>
#include "base/message_loop.h"
@ -112,7 +113,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
bool processing_incoming_;
// This flag is set after Close() is run on the channel.
bool closed_;
std::atomic<bool> closed_;
// We keep track of the PID of the other side of this channel so that we can
// record this when generating logs of IPC messages.
@ -122,7 +123,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
// read output_queue_length_ from any thread (if we're OK getting an
// occasional out-of-date or bogus value). We use output_queue_length_ to
// implement Unsound_NumQueuedMessages.
size_t output_queue_length_;
std::atomic<size_t> output_queue_length_;
ScopedRunnableMethodFactory<ChannelImpl> factory_;