summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_posix_unittest.cc
diff options
context:
space:
mode:
authorhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 23:00:38 +0000
committerhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 23:00:38 +0000
commit891ccf8ab73ea3f68852b9544d2db90ad70a9d65 (patch)
tree9bbf8eb7ce7ebef34a28e72909f07c87c9e7a2db /ipc/ipc_channel_posix_unittest.cc
parent1ad2709b515a805ca6dc3a8363bd3ae3cc7432f8 (diff)
downloadchromium_src-891ccf8ab73ea3f68852b9544d2db90ad70a9d65.zip
chromium_src-891ccf8ab73ea3f68852b9544d2db90ad70a9d65.tar.gz
chromium_src-891ccf8ab73ea3f68852b9544d2db90ad70a9d65.tar.bz2
Revert of Fix posix IPC channel hanging problem. (https://codereview.chromium.org/30133002/)
Reason for revert: Seems to cause some leaks. Reverting while I investigate. http://build.chromium.org/p/chromium.memory/builders/Linux%20ASAN%20Tests%20%282%29/builds/22398 Original issue's description: > Fix posix IPC channel hanging problem. > > If a channel closes right before a send call, listeners might not be notified of > the problem, which can cause hangs. This CL fixes that and adds a test that makes > sure that this does not happen in the future. > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=248060 TBR=cpu@chromium.org,shess@chromium.org,hubbe@google.com NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/150883002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_posix_unittest.cc')
-rw-r--r--ipc/ipc_channel_posix_unittest.cc53
1 files changed, 3 insertions, 50 deletions
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index fa983f6..dbd854e 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -41,9 +41,7 @@ class IPCChannelPosixTestListener : public IPC::Listener {
};
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 @@ class IPCChannelPosixTestListener : public IPC::Listener {
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 @@ void IPCChannelPosixTest::SpinRunLoop(base::TimeDelta delay) {
// 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();
}
@@ -236,45 +228,6 @@ 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 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) {
// Test creating a connection to an external process.
IPCChannelPosixTestListener listener(false);