From a3d929169f469682b23d64ad89f955fadd493da8 Mon Sep 17 00:00:00 2001
From: yang-g <yangg@google.com>
Date: Sat, 8 Jul 2017 00:57:20 -0700
Subject: [PATCH] Use pointer to avoid assignment and race.

---
 .../grpc++/impl/codegen/async_unary_call.h    | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h
index a5a698c640..41b3ae3f28 100644
--- a/include/grpc++/impl/codegen/async_unary_call.h
+++ b/include/grpc++/impl/codegen/async_unary_call.h
@@ -123,18 +123,18 @@ class ClientAsyncResponseReader final
   void ReadInitialMetadata(void* tag) {
     GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
 
-    Ops& o = ops_;
+    Ops* o = &ops_;
 
     // TODO(vjpai): Remove the collection_ specialization as soon
     // as the public constructor is deleted
     if (collection_) {
-      o = *collection_;
+      o = collection_.get();
       collection_->meta_buf.SetCollection(collection_);
     }
 
-    o.meta_buf.set_output_tag(tag);
-    o.meta_buf.RecvInitialMetadata(context_);
-    call_.PerformOps(&o.meta_buf);
+    o->meta_buf.set_output_tag(tag);
+    o->meta_buf.RecvInitialMetadata(context_);
+    call_.PerformOps(&o->meta_buf);
   }
 
   /// See \a ClientAysncResponseReaderInterface::Finish for semantics.
@@ -143,23 +143,23 @@ class ClientAsyncResponseReader final
   ///   - the \a ClientContext associated with this call is updated with
   ///     possible initial and trailing metadata sent from the server.
   void Finish(R* msg, Status* status, void* tag) {
-    Ops& o = ops_;
+    Ops* o = &ops_;
 
     // TODO(vjpai): Remove the collection_ specialization as soon
     // as the public constructor is deleted
     if (collection_) {
-      o = *collection_;
+      o = collection_.get();
       collection_->finish_buf.SetCollection(collection_);
     }
 
-    o.finish_buf.set_output_tag(tag);
+    o->finish_buf.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
-      o.finish_buf.RecvInitialMetadata(context_);
+      o->finish_buf.RecvInitialMetadata(context_);
     }
-    o.finish_buf.RecvMessage(msg);
-    o.finish_buf.AllowNoMessage();
-    o.finish_buf.ClientRecvStatus(context_, status);
-    call_.PerformOps(&o.finish_buf);
+    o->finish_buf.RecvMessage(msg);
+    o->finish_buf.AllowNoMessage();
+    o->finish_buf.ClientRecvStatus(context_, status);
+    call_.PerformOps(&o->finish_buf);
   }
 
  private:
-- 
GitLab