diff options
author | tschmelcher@google.com <tschmelcher@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 17:24:42 +0000 |
---|---|---|
committer | tschmelcher@google.com <tschmelcher@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 17:24:42 +0000 |
commit | 6e468fa6eee9aa59fd0f314391379a33081f8614 (patch) | |
tree | 900b8c93ac70bd9432f3452d34e22390e576626b /o3d | |
parent | de4b4e40ef3eae4bdf9530c452663d8a0cd07897 (diff) | |
download | chromium_src-6e468fa6eee9aa59fd0f314391379a33081f8614.zip chromium_src-6e468fa6eee9aa59fd0f314391379a33081f8614.tar.gz chromium_src-6e468fa6eee9aa59fd0f314391379a33081f8614.tar.bz2 |
Fix bugs where O3D would output lots of spurious log messages in the
case of blocking errors or EOFs on NACL handles.
Review URL: http://codereview.chromium.org/118258
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/core/cross/message_queue.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/o3d/core/cross/message_queue.cc b/o3d/core/cross/message_queue.cc index 58e860d..b36d1e9 100644 --- a/o3d/core/cross/message_queue.cc +++ b/o3d/core/cross/message_queue.cc @@ -224,15 +224,28 @@ bool MessageQueue::CheckForNewMessages() { // Check all the sockets of the connected clients to see if they contain any // messages. - std::vector<ConnectedClient*>::const_iterator iter; - for (iter = connected_clients_.begin(); iter < connected_clients_.end(); - ++iter) { + std::vector<ConnectedClient*>::iterator iter; + for (iter = connected_clients_.begin(); iter < connected_clients_.end();) { if (ReceiveMessageFromSocket((*iter)->client_handle(), &header, &message_id, &message_length)) { - ProcessClientRequest(*iter, message_length, message_id, &header, handles); + if (message_length == 0) { + // Message length of 0 means EOF (i.e., client closed its handle). + nacl::Close((*iter)->client_handle()); + delete *iter; + iter = connected_clients_.erase(iter); // Advances the iterator too. + continue; + } + if (message_length != -1) { // Else no message waiting + ProcessClientRequest(*iter, + message_length, + message_id, + &header, + handles); + } } + ++iter; } return true; @@ -261,12 +274,27 @@ bool MessageQueue::ReceiveMessageFromSocket(nacl::Handle socket, if (nacl::WouldBlock()) { *length = message_length; return true; +#if defined(OS_WIN) + } else if (GetLastError() == ERROR_BROKEN_PIPE) { + // On Windows, the NACL library treats EOF as a failure with this failure + // code. We convert it to the traditional format of a successful read that + // returns zero bytes to match the Mac & Linux case below. + *length = 0; + return true; +#endif } else { LOG_IMC_ERROR("nacl::ReceiveMessage failed"); return false; } } +#if defined(OS_MACOSX) | defined(OS_LINUX) + if (message_length == 0) { // EOF + *length = 0; + return true; + } +#endif + // Valid messages must always contain at least the ID of the message if (message_length >= sizeof(*message_id)) { // Check if the incoming message requires more space than we have |