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

Side by Side Diff: mojo/public/cpp/bindings/lib/connector.cc

Issue 401963002: Mojo: Make Connector::Accept() MOJO_CHECK-fail if it sees MOJO_RESULT_BUSY. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update string and comment Created 6 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/public/cpp/bindings/lib/connector.h" 5 #include "mojo/public/cpp/bindings/lib/connector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "mojo/public/cpp/bindings/error_handler.h" 9 #include "mojo/public/cpp/bindings/error_handler.h"
10 #include "mojo/public/cpp/environment/logging.h" 10 #include "mojo/public/cpp/environment/logging.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // to track their lifetime any longer. 90 // to track their lifetime any longer.
91 message->mutable_handles()->clear(); 91 message->mutable_handles()->clear();
92 break; 92 break;
93 case MOJO_RESULT_FAILED_PRECONDITION: 93 case MOJO_RESULT_FAILED_PRECONDITION:
94 // There's no point in continuing to write to this pipe since the other 94 // There's no point in continuing to write to this pipe since the other
95 // end is gone. Avoid writing any future messages. Hide write failures 95 // end is gone. Avoid writing any future messages. Hide write failures
96 // from the caller since we'd like them to continue consuming any backlog 96 // from the caller since we'd like them to continue consuming any backlog
97 // of incoming messages before regarding the message pipe as closed. 97 // of incoming messages before regarding the message pipe as closed.
98 drop_writes_ = true; 98 drop_writes_ = true;
99 break; 99 break;
100 case MOJO_RESULT_BUSY:
101 // We'd get a "busy" result if one of the message's handles is:
102 // - |message_pipe_|'s own handle;
103 // - simultaneously being used on another thread; or
104 // - in a "busy" state that prohibits it from being transferred (e.g.,
105 // a data pipe handle in the middle of a two-phase read/write,
106 // regardless of which thread that two-phase read/write is happening
107 // on).
108 // TODO(vtl): I wonder if this should be a |MOJO_DCHECK()|. (But, until
109 // crbug.com/389666, etc. are resolved, this will make tests fail quickly
110 // rather than hanging.)
111 MOJO_CHECK(false) << "Race condition or other bug detected";
112 return false;
100 default: 113 default:
101 // This particular write was rejected, presumably because of bad input. 114 // This particular write was rejected, presumably because of bad input.
102 // The pipe is not necessarily in a bad state. 115 // The pipe is not necessarily in a bad state.
103 return false; 116 return false;
104 } 117 }
105 return true; 118 return true;
106 } 119 }
107 120
108 // static 121 // static
109 void Connector::CallOnHandleReady(void* closure, MojoResult result) { 122 void Connector::CallOnHandleReady(void* closure, MojoResult result) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // should end early. 196 // should end early.
184 if (destroyed_flag_) { 197 if (destroyed_flag_) {
185 *destroyed_flag_ = true; // Propagate flag. 198 *destroyed_flag_ = true; // Propagate flag.
186 } 199 }
187 if (error_handler_) 200 if (error_handler_)
188 error_handler_->OnConnectionError(); 201 error_handler_->OnConnectionError();
189 } 202 }
190 203
191 } // namespace internal 204 } // namespace internal
192 } // namespace mojo 205 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698