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

Unified Diff: services/tracing/service.cc

Issue 2744943002: Mojo: Move waiting APIs to public library (Closed)
Patch Set: . Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/js/tests/core_unittest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/tracing/service.cc
diff --git a/services/tracing/service.cc b/services/tracing/service.cc
index f2a6c3b3ad4dc0751715fa70ce3481de17270f52..aca1ec5ed687109d5262c56b6842378a4f95560c 100644
--- a/services/tracing/service.cc
+++ b/services/tracing/service.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/system/wait.h"
#include "services/service_manager/public/cpp/interface_registry.h"
namespace tracing {
@@ -94,7 +95,7 @@ void Service::StopAndFlush() {
// done, close the collector pipe. We don't know how long they will take. We
// want to read all data that any collector might send until all collectors or
// closed or an (arbitrary) deadline has passed. Since the bindings don't
- // support this directly we do our own MojoWaitMany over the handles and read
+ // support this directly we do our own WaitMany over the handles and read
// individual messages until all are closed or our absolute deadline has
// elapsed.
static const MojoDeadline kTimeToWaitMicros = 1000 * 1000;
@@ -105,7 +106,6 @@ void Service::StopAndFlush() {
if (now >= end) // Timed out?
break;
- MojoDeadline mojo_deadline = end - now;
std::vector<mojo::Handle> handles;
std::vector<MojoHandleSignals> signals;
for (const auto& it : recorder_impls_) {
@@ -114,14 +114,14 @@ void Service::StopAndFlush() {
MOJO_HANDLE_SIGNAL_PEER_CLOSED);
}
std::vector<MojoHandleSignalsState> signals_states(signals.size());
- const mojo::WaitManyResult wait_many_result =
- mojo::WaitMany(handles, signals, mojo_deadline, &signals_states);
- if (wait_many_result.result == MOJO_RESULT_DEADLINE_EXCEEDED) {
- // Timed out waiting, nothing more to read.
- LOG(WARNING) << "Timed out waiting for trace flush";
- break;
- }
- if (wait_many_result.IsIndexValid()) {
+ size_t result_index;
+
+ // TODO(rockot): Use a timed wait here to avoid hanging forever in the case
+ // of a misbehaving or unresponsive collector.
+ MojoResult rv =
+ mojo::WaitMany(handles.data(), signals.data(), handles.size(),
+ &result_index, signals_states.data());
+ if (rv == MOJO_RESULT_OK || rv == MOJO_RESULT_FAILED_PRECONDITION) {
// Iterate backwards so we can remove closed pipes from |recorder_impls_|
// without invalidating subsequent offsets.
for (size_t i = signals_states.size(); i != 0; --i) {
« no previous file with comments | « mojo/public/js/tests/core_unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698