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

Unified Diff: ipc/unix_domain_socket_util_unittest.cc

Issue 2468593002: Fix undefined behavior in UnixDomainSocketUtil.Connect test. (Closed)
Patch Set: run ipc_tests on UBSan buildbots. Created 4 years, 1 month 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 | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/unix_domain_socket_util_unittest.cc
diff --git a/ipc/unix_domain_socket_util_unittest.cc b/ipc/unix_domain_socket_util_unittest.cc
index 467be89af985521d0056102fb12088134bf833fa..3b39abc2f33f047ed1e68d7268f96e708c870cbe 100644
--- a/ipc/unix_domain_socket_util_unittest.cc
+++ b/ipc/unix_domain_socket_util_unittest.cc
@@ -31,6 +31,9 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
started_watching_event_(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED),
+ stopped_watching_event_(
+ base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
accepted_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED) {
target_thread->PostTask(FROM_HERE,
@@ -55,7 +58,8 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
if (watcher_.get()) {
target_thread_->PostTask(FROM_HERE,
base::Bind(&SocketAcceptor::StopWatching, base::Unretained(this),
- watcher_.release()));
+ watcher_.release()));
+ stopped_watching_event_.Wait();
}
}
@@ -69,6 +73,7 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
void StopWatching(base::MessageLoopForIO::FileDescriptorWatcher* watcher) {
watcher->StopWatchingFileDescriptor();
delete watcher;
+ stopped_watching_event_.Signal();
}
void OnFileCanReadWithoutBlocking(int fd) override {
ASSERT_EQ(-1, server_fd_);
@@ -82,6 +87,7 @@ class SocketAcceptor : public base::MessageLoopForIO::Watcher {
base::SingleThreadTaskRunner* target_thread_;
std::unique_ptr<base::MessageLoopForIO::FileDescriptorWatcher> watcher_;
base::WaitableEvent started_watching_event_;
+ base::WaitableEvent stopped_watching_event_;
base::WaitableEvent accepted_event_;
DISALLOW_COPY_AND_ASSIGN(SocketAcceptor);
« no previous file with comments | « no previous file | testing/buildbot/chromium.fyi.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698