Index: mojo/edk/system/core.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/core.cc b/mojo/edk/system/core.cc |
similarity index 71% |
copy from third_party/mojo/src/mojo/edk/system/core.cc |
copy to mojo/edk/system/core.cc |
index c2b01361ce7c3b1833531fe5f5c28ac48858cacb..06f5b4a7dd6c1aa001fad1d36fe4e5a07608f51a 100644 |
--- a/third_party/mojo/src/mojo/edk/system/core.cc |
+++ b/mojo/edk/system/core.cc |
@@ -2,31 +2,30 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "third_party/mojo/src/mojo/edk/system/core.h" |
+#include "mojo/edk/system/core.h" |
#include <vector> |
#include "base/logging.h" |
#include "base/time/time.h" |
+#include "mojo/edk/embedder/platform_channel_pair.h" |
+#include "mojo/edk/embedder/platform_shared_buffer.h" |
+#include "mojo/edk/embedder/platform_support.h" |
+#include "mojo/edk/system/async_waiter.h" |
+#include "mojo/edk/system/configuration.h" |
+#include "mojo/edk/system/data_pipe.h" |
+#include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
+#include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
+#include "mojo/edk/system/dispatcher.h" |
+#include "mojo/edk/system/handle_signals_state.h" |
+#include "mojo/edk/system/message_pipe_dispatcher.h" |
+#include "mojo/edk/system/shared_buffer_dispatcher.h" |
+#include "mojo/edk/system/waiter.h" |
#include "mojo/public/c/system/macros.h" |
#include "mojo/public/cpp/system/macros.h" |
-#include "third_party/mojo/src/mojo/edk/embedder/platform_shared_buffer.h" |
-#include "third_party/mojo/src/mojo/edk/embedder/platform_support.h" |
-#include "third_party/mojo/src/mojo/edk/system/async_waiter.h" |
-#include "third_party/mojo/src/mojo/edk/system/configuration.h" |
-#include "third_party/mojo/src/mojo/edk/system/data_pipe.h" |
-#include "third_party/mojo/src/mojo/edk/system/data_pipe_consumer_dispatcher.h" |
-#include "third_party/mojo/src/mojo/edk/system/data_pipe_producer_dispatcher.h" |
-#include "third_party/mojo/src/mojo/edk/system/dispatcher.h" |
-#include "third_party/mojo/src/mojo/edk/system/handle_signals_state.h" |
-#include "third_party/mojo/src/mojo/edk/system/memory.h" |
-#include "third_party/mojo/src/mojo/edk/system/message_pipe.h" |
-#include "third_party/mojo/src/mojo/edk/system/message_pipe_dispatcher.h" |
-#include "third_party/mojo/src/mojo/edk/system/shared_buffer_dispatcher.h" |
-#include "third_party/mojo/src/mojo/edk/system/waiter.h" |
namespace mojo { |
-namespace system { |
+namespace edk { |
// Implementation notes |
// |
@@ -78,7 +77,7 @@ namespace system { |
// held. |
// TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter. |
-Core::Core(embedder::PlatformSupport* platform_support) |
+Core::Core(PlatformSupport* platform_support) |
: platform_support_(platform_support) { |
} |
@@ -86,7 +85,7 @@ Core::~Core() { |
} |
MojoHandle Core::AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher) { |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
return handle_table_.AddDispatcher(dispatcher); |
} |
@@ -94,7 +93,7 @@ scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { |
if (handle == MOJO_HANDLE_INVALID) |
return nullptr; |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
return handle_table_.GetDispatcher(handle); |
} |
@@ -103,7 +102,7 @@ MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle, |
if (handle == MOJO_HANDLE_INVALID) |
return MOJO_RESULT_INVALID_ARGUMENT; |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
return handle_table_.GetAndRemoveDispatcher(handle, dispatcher); |
} |
@@ -130,7 +129,7 @@ MojoResult Core::Close(MojoHandle handle) { |
scoped_refptr<Dispatcher> dispatcher; |
{ |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
MojoResult result = |
handle_table_.GetAndRemoveDispatcher(handle, &dispatcher); |
if (result != MOJO_RESULT_OK) |
@@ -138,7 +137,7 @@ MojoResult Core::Close(MojoHandle handle) { |
} |
// The dispatcher doesn't have a say in being closed, but gets notified of it. |
- // Note: This is done outside of |handle_table_mutex_|. As a result, there's a |
+ // Note: This is done outside of |handle_table_lock_|. As a result, there's a |
// race condition that the dispatcher must handle; see the comment in |
// |Dispatcher| in dispatcher.h. |
return dispatcher->Close(); |
@@ -147,57 +146,49 @@ MojoResult Core::Close(MojoHandle handle) { |
MojoResult Core::Wait(MojoHandle handle, |
MojoHandleSignals signals, |
MojoDeadline deadline, |
- UserPointer<MojoHandleSignalsState> signals_state) { |
+ MojoHandleSignalsState* signals_state) { |
uint32_t unused = static_cast<uint32_t>(-1); |
HandleSignalsState hss; |
MojoResult rv = WaitManyInternal(&handle, &signals, 1, deadline, &unused, |
- signals_state.IsNull() ? nullptr : &hss); |
- if (rv != MOJO_RESULT_INVALID_ARGUMENT && !signals_state.IsNull()) |
- signals_state.Put(hss); |
+ signals_state ? &hss : nullptr); |
+ if (rv != MOJO_RESULT_INVALID_ARGUMENT && signals_state) |
+ *signals_state = hss; |
return rv; |
} |
-MojoResult Core::WaitMany(UserPointer<const MojoHandle> handles, |
- UserPointer<const MojoHandleSignals> signals, |
+MojoResult Core::WaitMany(const MojoHandle* handles, |
+ const MojoHandleSignals* signals, |
uint32_t num_handles, |
MojoDeadline deadline, |
- UserPointer<uint32_t> result_index, |
- UserPointer<MojoHandleSignalsState> signals_states) { |
+ uint32_t* result_index, |
+ MojoHandleSignalsState* signals_state) { |
if (num_handles < 1) |
return MOJO_RESULT_INVALID_ARGUMENT; |
if (num_handles > GetConfiguration().max_wait_many_num_handles) |
return MOJO_RESULT_RESOURCE_EXHAUSTED; |
- UserPointer<const MojoHandle>::Reader handles_reader(handles, num_handles); |
- UserPointer<const MojoHandleSignals>::Reader signals_reader(signals, |
- num_handles); |
- uint32_t index = static_cast<uint32_t>(-1); |
+ uint32_t index = static_cast<uint32_t>(-1); |
MojoResult rv; |
- if (signals_states.IsNull()) { |
- rv = WaitManyInternal(handles_reader.GetPointer(), |
- signals_reader.GetPointer(), num_handles, deadline, |
- &index, nullptr); |
- } else { |
- UserPointer<MojoHandleSignalsState>::Writer signals_states_writer( |
- signals_states, num_handles); |
- // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a |
+ if (!signals_state) { |
+ rv = WaitManyInternal(handles, signals, num_handles, deadline, &index, |
+ nullptr); |
+ } else { |
+ // Note: The |reinterpret_cast| is safe, since |HandleSignalsState| is a |
// subclass of |MojoHandleSignalsState| that doesn't add any data members. |
- rv = WaitManyInternal(handles_reader.GetPointer(), |
- signals_reader.GetPointer(), num_handles, deadline, |
- &index, reinterpret_cast<HandleSignalsState*>( |
- signals_states_writer.GetPointer())); |
- if (rv != MOJO_RESULT_INVALID_ARGUMENT) |
- signals_states_writer.Commit(); |
- } |
- if (index != static_cast<uint32_t>(-1) && !result_index.IsNull()) |
- result_index.Put(index); |
+ rv = WaitManyInternal(handles, signals, num_handles, deadline, &index, |
+ reinterpret_cast<HandleSignalsState*>(signals_state)); |
+ } |
+ if (index != static_cast<uint32_t>(-1) && result_index) |
+ *result_index = index; |
return rv; |
} |
MojoResult Core::CreateMessagePipe( |
- UserPointer<const MojoCreateMessagePipeOptions> options, |
- UserPointer<MojoHandle> message_pipe_handle0, |
- UserPointer<MojoHandle> message_pipe_handle1) { |
+ const MojoCreateMessagePipeOptions* options, |
+ MojoHandle* message_pipe_handle0, |
+ MojoHandle* message_pipe_handle1) { |
+ CHECK(message_pipe_handle0); |
+ CHECK(message_pipe_handle1); |
MojoCreateMessagePipeOptions validated_options = {}; |
MojoResult result = |
MessagePipeDispatcher::ValidateCreateOptions(options, &validated_options); |
@@ -211,7 +202,7 @@ MojoResult Core::CreateMessagePipe( |
std::pair<MojoHandle, MojoHandle> handle_pair; |
{ |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1); |
} |
if (handle_pair.first == MOJO_HANDLE_INVALID) { |
@@ -222,12 +213,12 @@ MojoResult Core::CreateMessagePipe( |
return MOJO_RESULT_RESOURCE_EXHAUSTED; |
} |
- scoped_refptr<MessagePipe> message_pipe(MessagePipe::CreateLocalLocal()); |
- dispatcher0->Init(message_pipe, 0); |
- dispatcher1->Init(message_pipe, 1); |
+ PlatformChannelPair channel_pair; |
+ dispatcher0->Init(channel_pair.PassServerHandle()); |
+ dispatcher1->Init(channel_pair.PassClientHandle()); |
- message_pipe_handle0.Put(handle_pair.first); |
- message_pipe_handle1.Put(handle_pair.second); |
+ *message_pipe_handle0 = handle_pair.first; |
+ *message_pipe_handle1 = handle_pair.second; |
return MOJO_RESULT_OK; |
} |
@@ -239,9 +230,9 @@ MojoResult Core::CreateMessagePipe( |
// after the the message has been received and a new handle created (and |
// possibly even after calls have been made on the new handle). |
MojoResult Core::WriteMessage(MojoHandle message_pipe_handle, |
- UserPointer<const void> bytes, |
+ const void* bytes, |
uint32_t num_bytes, |
- UserPointer<const MojoHandle> handles, |
+ const MojoHandle* handles, |
uint32_t num_handles, |
MojoWriteMessageFlags flags) { |
scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle)); |
@@ -263,8 +254,6 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle, |
if (num_handles > GetConfiguration().max_message_num_handles) |
return MOJO_RESULT_RESOURCE_EXHAUSTED; |
- UserPointer<const MojoHandle>::Reader handles_reader(handles, num_handles); |
- |
// We'll need to hold on to the dispatchers so that we can pass them on to |
// |WriteMessage()| and also so that we can unlock their locks afterwards |
// without accessing the handle table. These can be dumb pointers, since their |
@@ -276,10 +265,9 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle, |
// and mark the handles as busy. If the call succeeds, we then remove the |
// handles from the handle table. |
{ |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
MojoResult result = handle_table_.MarkBusyAndStartTransport( |
- message_pipe_handle, handles_reader.GetPointer(), num_handles, |
- &transports); |
+ message_pipe_handle, handles, num_handles, &transports); |
if (result != MOJO_RESULT_OK) |
return result; |
} |
@@ -293,12 +281,11 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle, |
transports[i].End(); |
{ |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
if (rv == MOJO_RESULT_OK) { |
- handle_table_.RemoveBusyHandles(handles_reader.GetPointer(), num_handles); |
+ handle_table_.RemoveBusyHandles(handles, num_handles); |
} else { |
- handle_table_.RestoreBusyHandles(handles_reader.GetPointer(), |
- num_handles); |
+ handle_table_.RestoreBusyHandles(handles, num_handles); |
} |
} |
@@ -306,18 +293,17 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle, |
} |
MojoResult Core::ReadMessage(MojoHandle message_pipe_handle, |
- UserPointer<void> bytes, |
- UserPointer<uint32_t> num_bytes, |
- UserPointer<MojoHandle> handles, |
- UserPointer<uint32_t> num_handles, |
+ void* bytes, |
+ uint32_t* num_bytes, |
+ MojoHandle* handles, |
+ uint32_t* num_handles, |
MojoReadMessageFlags flags) { |
scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle)); |
if (!dispatcher) |
return MOJO_RESULT_INVALID_ARGUMENT; |
- uint32_t num_handles_value = num_handles.IsNull() ? 0 : num_handles.Get(); |
- |
MojoResult rv; |
+ uint32_t num_handles_value = num_handles ? *num_handles : 0; |
if (num_handles_value == 0) { |
// Easy case: won't receive any handles. |
rv = dispatcher->ReadMessage(bytes, num_bytes, nullptr, &num_handles_value, |
@@ -328,20 +314,15 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle, |
&num_handles_value, flags); |
if (!dispatchers.empty()) { |
DCHECK_EQ(rv, MOJO_RESULT_OK); |
- DCHECK(!num_handles.IsNull()); |
+ DCHECK(num_handles); |
DCHECK_LE(dispatchers.size(), static_cast<size_t>(num_handles_value)); |
bool success; |
- UserPointer<MojoHandle>::Writer handles_writer(handles, |
- dispatchers.size()); |
{ |
- MutexLocker locker(&handle_table_mutex_); |
- success = handle_table_.AddDispatcherVector( |
- dispatchers, handles_writer.GetPointer()); |
+ base::AutoLock locker(handle_table_lock_); |
+ success = handle_table_.AddDispatcherVector(dispatchers, handles); |
} |
- if (success) { |
- handles_writer.Commit(); |
- } else { |
+ if (!success) { |
LOG(ERROR) << "Received message with " << dispatchers.size() |
<< " handles, but handle table full"; |
// Close dispatchers (outside the lock). |
@@ -355,15 +336,15 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle, |
} |
} |
- if (!num_handles.IsNull()) |
- num_handles.Put(num_handles_value); |
+ if (num_handles) |
+ *num_handles = num_handles_value; |
return rv; |
} |
MojoResult Core::CreateDataPipe( |
- UserPointer<const MojoCreateDataPipeOptions> options, |
- UserPointer<MojoHandle> data_pipe_producer_handle, |
- UserPointer<MojoHandle> data_pipe_consumer_handle) { |
+ const MojoCreateDataPipeOptions* options, |
+ MojoHandle* data_pipe_producer_handle, |
+ MojoHandle* data_pipe_consumer_handle) { |
MojoCreateDataPipeOptions validated_options = {}; |
MojoResult result = |
DataPipe::ValidateCreateOptions(options, &validated_options); |
@@ -371,13 +352,13 @@ MojoResult Core::CreateDataPipe( |
return result; |
scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher = |
- DataPipeProducerDispatcher::Create(); |
+ DataPipeProducerDispatcher::Create(validated_options); |
scoped_refptr<DataPipeConsumerDispatcher> consumer_dispatcher = |
- DataPipeConsumerDispatcher::Create(); |
+ DataPipeConsumerDispatcher::Create(validated_options); |
std::pair<MojoHandle, MojoHandle> handle_pair; |
{ |
- MutexLocker locker(&handle_table_mutex_); |
+ base::AutoLock locker(handle_table_lock_); |
handle_pair = handle_table_.AddDispatcherPair(producer_dispatcher, |
consumer_dispatcher); |
} |
@@ -390,18 +371,18 @@ MojoResult Core::CreateDataPipe( |
} |
DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID); |
- scoped_refptr<DataPipe> data_pipe(DataPipe::CreateLocal(validated_options)); |
- producer_dispatcher->Init(data_pipe); |
- consumer_dispatcher->Init(data_pipe); |
+ PlatformChannelPair channel_pair; |
+ producer_dispatcher->Init(channel_pair.PassServerHandle()); |
+ consumer_dispatcher->Init(channel_pair.PassClientHandle()); |
- data_pipe_producer_handle.Put(handle_pair.first); |
- data_pipe_consumer_handle.Put(handle_pair.second); |
+ *data_pipe_producer_handle = handle_pair.first; |
+ *data_pipe_consumer_handle = handle_pair.second; |
return MOJO_RESULT_OK; |
} |
MojoResult Core::WriteData(MojoHandle data_pipe_producer_handle, |
- UserPointer<const void> elements, |
- UserPointer<uint32_t> num_bytes, |
+ const void* elements, |
+ uint32_t* num_bytes, |
MojoWriteDataFlags flags) { |
scoped_refptr<Dispatcher> dispatcher( |
GetDispatcher(data_pipe_producer_handle)); |
@@ -412,8 +393,8 @@ MojoResult Core::WriteData(MojoHandle data_pipe_producer_handle, |
} |
MojoResult Core::BeginWriteData(MojoHandle data_pipe_producer_handle, |
- UserPointer<void*> buffer, |
- UserPointer<uint32_t> buffer_num_bytes, |
+ void** buffer, |
+ uint32_t* buffer_num_bytes, |
MojoWriteDataFlags flags) { |
scoped_refptr<Dispatcher> dispatcher( |
GetDispatcher(data_pipe_producer_handle)); |
@@ -434,8 +415,8 @@ MojoResult Core::EndWriteData(MojoHandle data_pipe_producer_handle, |
} |
MojoResult Core::ReadData(MojoHandle data_pipe_consumer_handle, |
- UserPointer<void> elements, |
- UserPointer<uint32_t> num_bytes, |
+ void* elements, |
+ uint32_t* num_bytes, |
MojoReadDataFlags flags) { |
scoped_refptr<Dispatcher> dispatcher( |
GetDispatcher(data_pipe_consumer_handle)); |
@@ -446,8 +427,8 @@ MojoResult Core::ReadData(MojoHandle data_pipe_consumer_handle, |
} |
MojoResult Core::BeginReadData(MojoHandle data_pipe_consumer_handle, |
- UserPointer<const void*> buffer, |
- UserPointer<uint32_t> buffer_num_bytes, |
+ const void** buffer, |
+ uint32_t* buffer_num_bytes, |
MojoReadDataFlags flags) { |
scoped_refptr<Dispatcher> dispatcher( |
GetDispatcher(data_pipe_consumer_handle)); |
@@ -468,9 +449,9 @@ MojoResult Core::EndReadData(MojoHandle data_pipe_consumer_handle, |
} |
MojoResult Core::CreateSharedBuffer( |
- UserPointer<const MojoCreateSharedBufferOptions> options, |
+ const MojoCreateSharedBufferOptions* options, |
uint64_t num_bytes, |
- UserPointer<MojoHandle> shared_buffer_handle) { |
+ MojoHandle* shared_buffer_handle) { |
MojoCreateSharedBufferOptions validated_options = {}; |
MojoResult result = SharedBufferDispatcher::ValidateCreateOptions( |
options, &validated_options); |
@@ -485,21 +466,20 @@ MojoResult Core::CreateSharedBuffer( |
return result; |
} |
- MojoHandle h = AddDispatcher(dispatcher); |
- if (h == MOJO_HANDLE_INVALID) { |
+ *shared_buffer_handle = AddDispatcher(dispatcher); |
+ if (*shared_buffer_handle == MOJO_HANDLE_INVALID) { |
LOG(ERROR) << "Handle table full"; |
dispatcher->Close(); |
return MOJO_RESULT_RESOURCE_EXHAUSTED; |
} |
- shared_buffer_handle.Put(h); |
return MOJO_RESULT_OK; |
} |
MojoResult Core::DuplicateBufferHandle( |
MojoHandle buffer_handle, |
- UserPointer<const MojoDuplicateBufferHandleOptions> options, |
- UserPointer<MojoHandle> new_buffer_handle) { |
+ const MojoDuplicateBufferHandleOptions* options, |
+ MojoHandle* new_buffer_handle) { |
scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle)); |
if (!dispatcher) |
return MOJO_RESULT_INVALID_ARGUMENT; |
@@ -511,27 +491,26 @@ MojoResult Core::DuplicateBufferHandle( |
if (result != MOJO_RESULT_OK) |
return result; |
- MojoHandle new_handle = AddDispatcher(new_dispatcher); |
- if (new_handle == MOJO_HANDLE_INVALID) { |
+ *new_buffer_handle = AddDispatcher(new_dispatcher); |
+ if (*new_buffer_handle == MOJO_HANDLE_INVALID) { |
LOG(ERROR) << "Handle table full"; |
dispatcher->Close(); |
return MOJO_RESULT_RESOURCE_EXHAUSTED; |
} |
- new_buffer_handle.Put(new_handle); |
return MOJO_RESULT_OK; |
} |
MojoResult Core::MapBuffer(MojoHandle buffer_handle, |
uint64_t offset, |
uint64_t num_bytes, |
- UserPointer<void*> buffer, |
+ void** buffer, |
MojoMapBufferFlags flags) { |
scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle)); |
if (!dispatcher) |
return MOJO_RESULT_INVALID_ARGUMENT; |
- scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; |
+ scoped_ptr<PlatformSharedBufferMapping> mapping; |
MojoResult result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping); |
if (result != MOJO_RESULT_OK) |
return result; |
@@ -539,19 +518,19 @@ MojoResult Core::MapBuffer(MojoHandle buffer_handle, |
DCHECK(mapping); |
void* address = mapping->GetBase(); |
{ |
- MutexLocker locker(&mapping_table_mutex_); |
+ base::AutoLock locker(mapping_table_lock_); |
result = mapping_table_.AddMapping(mapping.Pass()); |
} |
if (result != MOJO_RESULT_OK) |
return result; |
- buffer.Put(address); |
+ *buffer = address; |
return MOJO_RESULT_OK; |
} |
-MojoResult Core::UnmapBuffer(UserPointer<void> buffer) { |
- MutexLocker locker(&mapping_table_mutex_); |
- return mapping_table_.RemoveMapping(buffer.GetPointerValue()); |
+MojoResult Core::UnmapBuffer(void* buffer) { |
+ base::AutoLock locker(mapping_table_lock_); |
+ return mapping_table_.RemoveMapping(buffer); |
} |
// Note: We allow |handles| to repeat the same handle multiple times, since |
@@ -564,15 +543,20 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles, |
MojoDeadline deadline, |
uint32_t* result_index, |
HandleSignalsState* signals_states) { |
+ CHECK(handles); |
+ CHECK(signals); |
DCHECK_GT(num_handles, 0u); |
- DCHECK_EQ(*result_index, static_cast<uint32_t>(-1)); |
+ if (result_index) { |
+ DCHECK_EQ(*result_index, static_cast<uint32_t>(-1)); |
+ } |
DispatcherVector dispatchers; |
dispatchers.reserve(num_handles); |
for (uint32_t i = 0; i < num_handles; i++) { |
scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handles[i]); |
if (!dispatcher) { |
- *result_index = i; |
+ if (result_index && result_index) |
brucedawson
2015/10/05 16:50:26
The /analyze builder points out that this line of
|
+ *result_index = i; |
return MOJO_RESULT_INVALID_ARGUMENT; |
} |
dispatchers.push_back(dispatcher); |
@@ -588,7 +572,8 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles, |
rv = dispatchers[i]->AddAwakable( |
&waiter, signals[i], i, signals_states ? &signals_states[i] : nullptr); |
if (rv != MOJO_RESULT_OK) { |
- *result_index = i; |
+ if (result_index) |
+ *result_index = i; |
break; |
} |
} |
@@ -614,5 +599,5 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles, |
return rv; |
} |
-} // namespace system |
+} // namespace edk |
} // namespace mojo |