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

Unified Diff: ipc/ipc_channel_posix_unittest.cc

Issue 30133002: Fix posix IPC channel hanging problem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actual fix Created 7 years, 2 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
« ipc/ipc_channel_posix.cc ('K') | « 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 66ddeb2b49676444245ceab4e185a0dd84e926b8..4cbf9c0a22b89e061adfab43c4754cb72ddf4cfd 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -228,6 +228,28 @@ TEST_F(IPCChannelPosixTest, BasicConnected) {
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 unforunate 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());
+}
+
TEST_F(IPCChannelPosixTest, AdvancedConnected) {
// Test creating a connection to an external process.
IPCChannelPosixTestListener listener(false);
« ipc/ipc_channel_posix.cc ('K') | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698