Index: mojo/public/cpp/bindings/lib/connector.cc |
diff --git a/mojo/public/cpp/bindings/lib/connector.cc b/mojo/public/cpp/bindings/lib/connector.cc |
index 812b4c1133f56db708729a82055cbb24e9671456..c7378f0b605b419e3e5d45a0e51a87d186a926f7 100644 |
--- a/mojo/public/cpp/bindings/lib/connector.cc |
+++ b/mojo/public/cpp/bindings/lib/connector.cc |
@@ -368,16 +368,18 @@ void Connector::HandleError(bool force_pipe_reset, bool force_async_handler) { |
if (error_ || !message_pipe_.is_valid()) |
return; |
- if (!force_pipe_reset && force_async_handler) |
- force_pipe_reset = true; |
- |
- if (paused_) { |
- // If the user has paused receiving messages, we shouldn't call the error |
- // handler right away. We need to wait until the user starts receiving |
- // messages again. |
+ if (during_sync_handle_watcher_callback() || paused_) { |
+ // Enforce calling the error handler asynchronously if: |
+ // - currently we are in a sync handle watcher callback. We don't want the |
+ // error handler to reenter an ongoing sync call. |
+ // - the user has paused receiving messages. We need to wait until the user |
+ // starts receiving messages again. |
force_async_handler = true; |
} |
+ if (!force_pipe_reset && force_async_handler) |
+ force_pipe_reset = true; |
+ |
if (force_pipe_reset) { |
CancelWait(); |
MayAutoLock locker(lock_.get()); |