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

Unified Diff: ipc/ipc_channel_posix_unittest.cc

Issue 170863002: Revert of Fix posix IPC channel hanging problem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_posix_unittest.cc
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index fa983f6158e93f01919d442f3b375314475806b6..dbd854e16c69813da66a9ec14d116ca9e6891784 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -41,9 +41,7 @@
};
IPCChannelPosixTestListener(bool quit_only_on_message)
- : status_(DISCONNECTED),
- quit_only_on_message_(quit_only_on_message) {
- }
+ : status_(DISCONNECTED), quit_only_on_message_(quit_only_on_message) {}
virtual ~IPCChannelPosixTestListener() {}
@@ -85,13 +83,7 @@
STATUS status() { return status_; }
void QuitRunLoop() {
- base::MessageLoopForIO* loop = base::MessageLoopForIO::current();
- if (loop->is_running()) {
- loop->QuitNow();
- } else {
- // Die as soon as Run is called.
- loop->PostTask(FROM_HERE, loop->QuitClosure());
- }
+ base::MessageLoopForIO::current()->QuitNow();
}
private:
@@ -194,7 +186,7 @@
// in the case of a bad test. Usually, the run loop will quit sooner than
// that because all tests use a IPCChannelPosixTestListener which quits the
// current run loop on any channel activity.
- loop->PostDelayedTask(FROM_HERE, loop->QuitClosure(), delay);
+ loop->PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), delay);
loop->Run();
}
@@ -234,45 +226,6 @@
IPC::Channel channel2(socket_name, IPC::Channel::MODE_SERVER, NULL);
ASSERT_TRUE(channel2.Connect());
ASSERT_FALSE(channel2.AcceptsConnections());
-}
-
-// If a connection closes right before a Send() call, we may end up closing
-// the connection without notifying the listener, which can cause hangs in
-// sync_message_filter and others. Make sure the listener is notified.
-TEST_F(IPCChannelPosixTest, SendHangTest) {
- IPCChannelPosixTestListener out_listener(true);
- IPCChannelPosixTestListener in_listener(true);
- IPC::ChannelHandle in_handle("IN");
- IPC::Channel in_chan(in_handle, IPC::Channel::MODE_SERVER, &in_listener);
- base::FileDescriptor out_fd(in_chan.TakeClientFileDescriptor(), false);
- IPC::ChannelHandle out_handle("OUT", out_fd);
- IPC::Channel out_chan(out_handle, IPC::Channel::MODE_CLIENT, &out_listener);
- ASSERT_TRUE(in_chan.Connect());
- ASSERT_TRUE(out_chan.Connect());
- in_chan.Close(); // simulate remote process dying at an unfortunate time.
- // Send will fail, because it cannot write the message.
- ASSERT_FALSE(out_chan.Send(new IPC::Message(
- 0, // routing_id
- kQuitMessage, // message type
- IPC::Message::PRIORITY_NORMAL)));
- ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, out_listener.status());
-}
-
-// If a connection closes right before a Connect() call, we may end up closing
-// the connection without notifying the listener, which can cause hangs in
-// sync_message_filter and others. Make sure the listener is notified.
-TEST_F(IPCChannelPosixTest, AcceptHangTest) {
- IPCChannelPosixTestListener out_listener(true);
- IPCChannelPosixTestListener in_listener(true);
- IPC::ChannelHandle in_handle("IN");
- IPC::Channel in_chan(in_handle, IPC::Channel::MODE_SERVER, &in_listener);
- base::FileDescriptor out_fd(in_chan.TakeClientFileDescriptor(), false);
- IPC::ChannelHandle out_handle("OUT", out_fd);
- IPC::Channel out_chan(out_handle, IPC::Channel::MODE_CLIENT, &out_listener);
- ASSERT_TRUE(in_chan.Connect());
- in_chan.Close(); // simulate remote process dying at an unfortunate time.
- ASSERT_FALSE(out_chan.Connect());
- ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, out_listener.status());
}
TEST_F(IPCChannelPosixTest, AdvancedConnected) {
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698