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

Side by Side Diff: ipc/ipc_channel_posix.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ipc/ipc_channel_posix_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_channel_posix.h" 5 #include "ipc/ipc_channel_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 << " with type " << message->type() 515 << " with type " << message->type()
516 << " (" << output_queue_.size() << " in queue)"; 516 << " (" << output_queue_.size() << " in queue)";
517 517
518 #ifdef IPC_MESSAGE_LOG_ENABLED 518 #ifdef IPC_MESSAGE_LOG_ENABLED
519 Logging::GetInstance()->OnSendMessage(message, ""); 519 Logging::GetInstance()->OnSendMessage(message, "");
520 #endif // IPC_MESSAGE_LOG_ENABLED 520 #endif // IPC_MESSAGE_LOG_ENABLED
521 521
522 message->TraceMessageBegin(); 522 message->TraceMessageBegin();
523 output_queue_.push(message); 523 output_queue_.push(message);
524 if (!is_blocked_on_write_ && !waiting_connect_) { 524 if (!is_blocked_on_write_ && !waiting_connect_) {
525 return ProcessOutgoingMessages(); 525 if (!ProcessOutgoingMessages()) {
526 ClosePipeOnError();
527 return false;
528 }
526 } 529 }
527 530
528 return true; 531 return true;
529 } 532 }
530 533
531 int Channel::ChannelImpl::GetClientFileDescriptor() { 534 int Channel::ChannelImpl::GetClientFileDescriptor() {
532 base::AutoLock lock(client_pipe_lock_); 535 base::AutoLock lock(client_pipe_lock_);
533 return client_pipe_; 536 return client_pipe_;
534 } 537 }
535 538
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 bool Channel::ChannelImpl::AcceptConnection() { 703 bool Channel::ChannelImpl::AcceptConnection() {
701 base::MessageLoopForIO::current()->WatchFileDescriptor( 704 base::MessageLoopForIO::current()->WatchFileDescriptor(
702 pipe_, true, base::MessageLoopForIO::WATCH_READ, &read_watcher_, this); 705 pipe_, true, base::MessageLoopForIO::WATCH_READ, &read_watcher_, this);
703 QueueHelloMessage(); 706 QueueHelloMessage();
704 707
705 if (mode_ & MODE_CLIENT_FLAG) { 708 if (mode_ & MODE_CLIENT_FLAG) {
706 // If we are a client we want to send a hello message out immediately. 709 // If we are a client we want to send a hello message out immediately.
707 // In server mode we will send a hello message when we receive one from a 710 // In server mode we will send a hello message when we receive one from a
708 // client. 711 // client.
709 waiting_connect_ = false; 712 waiting_connect_ = false;
710 return ProcessOutgoingMessages(); 713 return ProcessOutgoingMessages();
Scott Hess - ex-Googler 2013/10/22 23:52:46 Could this have the same race condition if the oth
hubbe 2013/10/23 00:29:28 Yes, I think so. I'll see if I can trigger this in
711 } else if (mode_ & MODE_SERVER_FLAG) { 714 } else if (mode_ & MODE_SERVER_FLAG) {
712 waiting_connect_ = true; 715 waiting_connect_ = true;
713 return true; 716 return true;
714 } else { 717 } else {
715 NOTREACHED(); 718 NOTREACHED();
716 return false; 719 return false;
717 } 720 }
718 } 721 }
719 722
720 void Channel::ChannelImpl::ClosePipeOnError() { 723 void Channel::ChannelImpl::ClosePipeOnError() {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1104
1102 1105
1103 #if defined(OS_LINUX) 1106 #if defined(OS_LINUX)
1104 // static 1107 // static
1105 void Channel::SetGlobalPid(int pid) { 1108 void Channel::SetGlobalPid(int pid) {
1106 ChannelImpl::SetGlobalPid(pid); 1109 ChannelImpl::SetGlobalPid(pid);
1107 } 1110 }
1108 #endif // OS_LINUX 1111 #endif // OS_LINUX
1109 1112
1110 } // namespace IPC 1113 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698