summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_channel_posix.cc
diff options
context:
space:
mode:
authorhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 22:31:10 +0000
committerhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-30 22:31:10 +0000
commitaf08fff586dbe75c43e170c13659a858ece07c09 (patch)
treefb4452a265cbbfb1d676c47f2d635baf55288496 /ipc/ipc_channel_posix.cc
parent065dffd4d219c9e69f6e799006ed569bb922aaa6 (diff)
downloadchromium_src-af08fff586dbe75c43e170c13659a858ece07c09.zip
chromium_src-af08fff586dbe75c43e170c13659a858ece07c09.tar.gz
chromium_src-af08fff586dbe75c43e170c13659a858ece07c09.tar.bz2
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. Review URL: https://codereview.chromium.org/30133002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_posix.cc')
-rw-r--r--ipc/ipc_channel_posix.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc
index 8788532..e539d4f 100644
--- a/ipc/ipc_channel_posix.cc
+++ b/ipc/ipc_channel_posix.cc
@@ -31,6 +31,7 @@
#include "base/posix/global_descriptors.h"
#include "base/process/process_handle.h"
#include "base/rand_util.h"
+#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
@@ -327,7 +328,7 @@ bool Channel::ChannelImpl::CreatePipe(
bool Channel::ChannelImpl::Connect() {
if (server_listen_pipe_ == -1 && pipe_ == -1) {
- DLOG(INFO) << "Channel creation failed: " << pipe_name_;
+ DLOG(WARNING) << "Channel creation failed: " << pipe_name_;
return false;
}
@@ -515,6 +516,9 @@ bool Channel::ChannelImpl::Send(Message* message) {
<< " with type " << message->type()
<< " (" << output_queue_.size() << " in queue)";
+ if (!waiting_connect_ && pipe_ == -1)
+ return false;
+
#ifdef IPC_MESSAGE_LOG_ENABLED
Logging::GetInstance()->OnSendMessage(message, "");
#endif // IPC_MESSAGE_LOG_ENABLED
@@ -522,7 +526,10 @@ bool Channel::ChannelImpl::Send(Message* message) {
message->TraceMessageBegin();
output_queue_.push(message);
if (!is_blocked_on_write_ && !waiting_connect_) {
- return ProcessOutgoingMessages();
+ if (!ProcessOutgoingMessages()) {
+ ClosePipeOnError();
+ return false;
+ }
}
return true;
@@ -707,7 +714,11 @@ bool Channel::ChannelImpl::AcceptConnection() {
// In server mode we will send a hello message when we receive one from a
// client.
waiting_connect_ = false;
- return ProcessOutgoingMessages();
+ if (!ProcessOutgoingMessages()) {
+ ClosePipeOnError();
+ return false;
+ }
+ return true;
} else if (mode_ & MODE_SERVER_FLAG) {
waiting_connect_ = true;
return true;